[Bug c++/103347] [9/10/11/12 Regression] Non-static data member initialization is erroneously allowed in C++03 with assignment to NULL

jakub at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Mon Nov 22 16:43:52 GMT 2021


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103347

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |dmalcolm at gcc dot gnu.org,
                   |                            |jakub at gcc dot gnu.org,
                   |                            |jason at gcc dot gnu.org,
                   |                            |mpolacek at gcc dot gnu.org

--- Comment #8 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Perhaps a faster way to fix this would be to try to warn on the = token rather
than on input_location which happens to be the location of NULL after
cp_parser_cache_defarg went through it.
For
struct test {
    int x = 1 + 2; //invalid in C++03 mode
};
we strangely warn with caret on the 2, for int x = (1 + 2); with caret on )
etc.
maybe_warn_cpp0x doesn't really take a location_t though, probably it should.
And grokdeclarator isn't called with the actual initializer (DEFERRED_PARSE)
from which we could dig up the location of the first token.


More information about the Gcc-bugs mailing list