This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c/60838] bugos warning: initializer element is not a constant expression: int test = (0 ? (1,0) : 0) + 1;


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60838

Marek Polacek <mpolacek at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |mpolacek at gcc dot gnu.org

--- Comment #2 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
I actually don't think this is a bug.  While C99/C11 say what you wrote about
Constant expressions, C89 says something else:
"Constant expressions shall not contain assignment, increment, decrement,
function-call, or comma operators, except when they are contained within the
operand of a sizeof operator."
And really:
int u = sizeof ((0 ? (3, 0) : 0) + 1);
issues no warnings even with -std=c89.  The default is still -std=gnu89, so you
may want to use e.g. -std=gnu99.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]