[Bug c++/33750] initialization of non-integral member constant not rejected
--- Comment #12 from pinskia at gcc dot gnu dot org 2007-12-02 22:11 --- *** This bug has been marked as a duplicate of 11393 *** -- pinskia at gcc dot gnu dot org changed: What|Removed |Added Status|UNCONFIRMED |RESOLVED Resolution||DUPLICATE http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33750
[Bug c++/33750] initialization of non-integral member constant not rejected
--- Comment #11 from pinskia at gcc dot gnu dot org 2007-10-12 16:31 --- try a dup of bu 11393? -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33750
[Bug c++/33750] initialization of non-integral member constant not rejected
--- Comment #10 from pcarlini at suse dot de 2007-10-12 16:29 --- Related to PR11393 ? -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33750
[Bug c++/33750] initialization of non-integral member constant not rejected
--- Comment #9 from gdr at cs dot tamu dot edu 2007-10-12 16:19 --- Subject: Re: initialization of non-integral member constant not rejected "rguenth at gcc dot gnu dot org" <[EMAIL PROTECTED]> writes: | We should also warn by default with -std=c++98 or -std=c++0x. I agree that we should do something for -std=c++98. For -std=c++0x, I introduced the notion of `literal type' in C++0x so that you can actually do more folding at compile time (including objects of class types), and you can initialize constexpr static data member objects of literal type in class definition. -- Gaby -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33750
[Bug c++/33750] initialization of non-integral member constant not rejected
--- Comment #8 from rguenth at gcc dot gnu dot org 2007-10-12 15:20 --- What probably adds to the confusion is that C++ defaults to give errors for pedwarns but has pedantic = 0. But it is only possible to re-set pedantic-errors with -fpermissive. So to get plain -pedantic you need -pedantic -fpermissive for C++ while -pedantic-errors works as expected. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33750
[Bug c++/33750] initialization of non-integral member constant not rejected
--- Comment #7 from bangerth at dealii dot org 2007-10-12 15:16 --- This used to be a GCC extension in the old days, which may explain why it isn't rejected by default. I believe it was deprecated several releases ago, you may find something to that effect in release notes... W. -- bangerth at dealii dot org changed: What|Removed |Added CC||bangerth at dealii dot org http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33750
[Bug c++/33750] initialization of non-integral member constant not rejected
--- Comment #6 from manu at gcc dot gnu dot org 2007-10-12 15:09 --- (In reply to comment #4) > We should also warn by default with -std=c++98 or -std=c++0x. > Why? Note that gnu++98 rejects more programs than c++98, sine the latter admits constructions that conflict with the GNU C++ language. Joseph explained it in PR28368. That is how "-std" works right now, but that PR is still open. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33750
[Bug c++/33750] initialization of non-integral member constant not rejected
--- Comment #5 from manu at gcc dot gnu dot org 2007-10-12 14:59 --- (In reply to comment #3) > > the first error message is always an error: > > static bool > cp_parser_non_integral_constant_expression (cp_parser *parser, > const char *thing) > { > parser->non_integral_constant_expression_p = true; > if (parser->integral_constant_expression_p) > { > if (!parser->allow_non_integral_constant_expression_p) > { > error ("%s cannot appear in a constant-expression", thing); > return true; > It seems that "-pedantic" is affecting parser->allow_non_integral_constant_expression_p somehow. Weird. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33750
[Bug c++/33750] initialization of non-integral member constant not rejected
--- Comment #4 from rguenth at gcc dot gnu dot org 2007-10-12 14:46 --- We should also warn by default with -std=c++98 or -std=c++0x. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33750
[Bug c++/33750] initialization of non-integral member constant not rejected
--- Comment #3 from rguenth at gcc dot gnu dot org 2007-10-12 14:45 --- >From diagnostic.c: /* A "pedantic" warning: issues a warning unless -pedantic-errors was given on the command line, in which case it issues an error. Use this for diagnostics required by the relevant language standard, if you have chosen not to make them errors. Note that these diagnostics are issued independent of the setting of the -pedantic command-line switch. To get a warning enabled only with that switch, write "if (pedantic) pedwarn (...);" */ void pedwarn (const char *gmsgid, ...) { But from c-opts.c: /* Adjust various flags for C++ based on command-line settings. */ if (c_dialect_cxx ()) { if (!flag_permissive) { flag_pedantic_errors = 1; cpp_opts->pedantic_errors = 1; } the first error message is always an error: static bool cp_parser_non_integral_constant_expression (cp_parser *parser, const char *thing) { parser->non_integral_constant_expression_p = true; if (parser->integral_constant_expression_p) { if (!parser->allow_non_integral_constant_expression_p) { error ("%s cannot appear in a constant-expression", thing); return true; -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33750
[Bug c++/33750] initialization of non-integral member constant not rejected
--- Comment #2 from rguenth at gcc dot gnu dot org 2007-10-12 14:38 --- No, -pedantic gives an error. -pedantic -fpermissive gives a warning on the initialization but still an error on the FP literal: tmp> g++-4.3 -c t.C tmp> g++-4.3 -c t.C -pedantic t.C:3: error: floating-point literal cannot appear in a constant-expression t.C:3: error: ISO C++ forbids initialization of member constant 'bar' of non-integral type 'const float' tmp> g++-4.3 -c t.C -pedantic -fpermissive t.C:3: error: floating-point literal cannot appear in a constant-expression t.C:3: warning: ISO C++ forbids initialization of member constant 'bar' of non-integral type 'const float' so I cannot get only warnings for this. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33750
[Bug c++/33750] initialization of non-integral member constant not rejected
--- Comment #1 from manu at gcc dot gnu dot org 2007-10-12 14:27 --- (In reply to comment #0) > why do we guard the pedwarn with if (pedantic)?? > -pedantic Issue all the warnings demanded by strict ISO C and ISO C++ (...) Valid ISO C and ISO C++ programs should compile properly with or without this option (...). However, without this option, certain GNU extensions and traditional C and C++ fea‐ tures are supported as well. With this option, they are rejected. So I guess that the program compiles and does what it is intended (thus we don't warn by default) but ISO C++ requires a warning, thus -pedantic gives the warning. -- manu at gcc dot gnu dot org changed: What|Removed |Added CC||manu at gcc dot gnu dot org http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33750