On Fri, May 13, 2016 at 11:07:18PM +0200, Cyril Bonté wrote:
> At this point, I have an issue in the function str2listener() [cfgparse.c]
> 
> In the port loop :
>   for (; port <= end; port++) {
>     [...]
>     if (l->addr.ss_family == AF_INET) {
>       [...]
> Here, if I print the content of :
>   ((struct sockaddr_in *)(&l->addr))->sin_addr.s_addr [1]
> I obtain 0 while I specified a "bind 127.0.0.1:10001".
> 
> But if first, I print the content of :
>   ((struct sockaddr_in *)(&ss))->sin_addr.s_addr [2]
> Both [1] and [2] will have the right value.
> 
> Once I compile with -O0, the issue disappears.
> I also don't have the issue if I replace :
>   ss = *ss2;
> with :
>   memcpy(&ss, ss2, sizeof(struct sockaddr_storage));

Wow that looks horribly messy! It seems like it's doing some mess
with structure alignments, padding, offsets or anything, but anyway
it's doing something wrong if it doesn't let us write valid C code
anymore. What is worse is that it produces bogus code, that's much
worse than refusing to build. The simple fact that it totally
changes the behaviour if you insert a line before indicates a bug
to me. It's been a very long time since I've met such a beast. I
think it should be reported, but for this a simple reproducer needs
to be found otherwise the authors will not be able to work on it,
which is understandable.

In the mean time, there may be a -fsomething option to disable a
bogus optimization which causes this, but that's not easy to spot
as it will depend on any side effect of other code :-/

So I'd strongly suggest that people don't use gcc6 for now. We may
add a check with a #error in compiler.h if that can protect users.

Thanks,
Willy


Reply via email to