[Bug c/60809] C99 struct initialiser with embedded self assignment

2014-04-29 Thread mpolacek at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60809

Marek Polacek  changed:

   What|Removed |Added

 Status|UNCONFIRMED |SUSPENDED
   Last reconfirmed||2014-04-30
 Ever confirmed|0   |1

--- Comment #7 from Marek Polacek  ---
(In reply to jos...@codesourcery.com from comment #6)
> I see nothing that says anything about the sequencing of side effects in 
> initialization expressions with respect to the actual initialization 
> itself, or parts thereof - either to require a particular sequencing, or 
> to make it indeterminately sequenced or unsequenced.  That may mean it's 
> implicitly unsequenced, but I'd suggest raising this with WG14.

Thanks, I'll try to report it then; suspending for now.


[Bug c/60809] C99 struct initialiser with embedded self assignment

2014-04-29 Thread joseph at codesourcery dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60809

--- Comment #6 from joseph at codesourcery dot com  ---
I see nothing that says anything about the sequencing of side effects in 
initialization expressions with respect to the actual initialization 
itself, or parts thereof - either to require a particular sequencing, or 
to make it indeterminately sequenced or unsequenced.  That may mean it's 
implicitly unsequenced, but I'd suggest raising this with WG14.


[Bug c/60809] C99 struct initialiser with embedded self assignment

2014-04-10 Thread jimis at gmx dot net
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60809

--- Comment #5 from jimis  ---
Andreas: On a second thought, this paragraph only talks about the order
*within* the initialisation list. But no matter of that order, the
initialisation list is always evaluated to:

{
.ai_family = AF_UNSPEC,
.ai_socktype = SOCK_STREAM,
AI_PASSIVE
};


The outer assignment to query2, should never set ai_flags, no matter what the
side-effects of the inner assignments are. Am I thinking right?


[Bug c/60809] C99 struct initialiser with embedded self assignment

2014-04-10 Thread jimis at gmx dot net
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60809

--- Comment #4 from jimis  ---
Thanks Andreas, that's the reference I was looking for!

I guess since this code triggers unspecified behaviour, a warning would be even
more needed. :-)


[Bug c/60809] C99 struct initialiser with embedded self assignment

2014-04-10 Thread sch...@linux-m68k.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60809

--- Comment #3 from Andreas Schwab  ---
6.7.9 Initialization
23 The evaluations of the initialization list expressions are indeterminately
sequenced with respect to one another and thus the order in which any side
effects occur is unspecified.


[Bug c/60809] C99 struct initialiser with embedded self assignment

2014-04-10 Thread jimis at gmx dot net
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60809

--- Comment #2 from jimis  ---
(In reply to Marek Polacek from comment #1)
> I see nothing surprising here; an assignment expression has the value of the
> left operand after the assignment.  So we 1) set query2.ai_flags to
> AI_PASSIVE, 2) use this value to initialize .ai_protocol.

if the outer assignment runs last, shouldn't it overwrite the inner assignment?
Then it should be equivalent to that:


struct addrinfo query3 = {
.ai_family = AF_UNSPEC,
.ai_socktype = SOCK_STREAM,
1


Which means that ai_flags should be 0.


[Bug c/60809] C99 struct initialiser with embedded self assignment

2014-04-10 Thread mpolacek at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60809

Marek Polacek  changed:

   What|Removed |Added

 CC||mpolacek at gcc dot gnu.org

--- Comment #1 from Marek Polacek  ---
I see nothing surprising here; an assignment expression has the value of the
left operand after the assignment.  So we 1) set query2.ai_flags to AI_PASSIVE,
2) use this value to initialize .ai_protocol.

I'm not sure a warning here makes sense: an assignment-expression is perfectly
valid initializer.