[Bug c++/65547] Gcc not giving preprocessor error for invalid invocation of variadic macro
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65547 --- Comment #5 from Jonathan Wakely redi at gcc dot gnu.org --- And as has been documented forever, the way to get diagnostics for GNU extensions that contradict the ISO standard is the -pedantic switch: https://gcc.gnu.org/onlinedocs/gcc-4.9.2/gcc/Warning-Options.html#index-pedantic-279 There is no bug here.
[Bug c++/65547] Gcc not giving preprocessor error for invalid invocation of variadic macro
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65547 --- Comment #4 from Jonathan Wakely redi at gcc dot gnu.org --- (In reply to Edward Diener from comment #3) Where do you get the idea that the standard doesn't require an error, it requires a diagnostic message ? 1.4 [intro.compliance], the text I quoted. Where do you get the idea it requires an error?
[Bug c++/65547] Gcc not giving preprocessor error for invalid invocation of variadic macro
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65547 --- Comment #6 from Edward Diener eldlistmailingz at tropicsoft dot com --- (In reply to Jonathan Wakely from comment #4) (In reply to Edward Diener from comment #3) Where do you get the idea that the standard doesn't require an error, it requires a diagnostic message ? 1.4 [intro.compliance], the text I quoted. Where do you get the idea it requires an error? You are not following the C++ standard as specified by the section I quoted. Does gcc just decide arbitrarily if it does not follow the C++ standard it can either issue an error, warning, or diagnostic message. That is an odd way to create a language compiler. Is not the idea of a compiler like gcc that it should follow the C++ standard as to be a standard-conforming compiler, and if the end-user writes C++ code that does not follow the C++ standard an error should be issued by the compiler ? I am clearly missing something here. The C++ standard, in the section/paragraph I quoted, is saying that when a macro accepts variadic parameters as its final parameter, some input, even if it is an argument consisting of no preprocessing tokens, must be passed for the variadic parameter. In the example I gave, no argument at all is being passed for the variadic parameter. If the invocation had been VMACRO(1,) then there is no problem. But some argument must be passed.
[Bug c++/65547] Gcc not giving preprocessor error for invalid invocation of variadic macro
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65547 --- Comment #7 from Edward Diener eldlistmailingz at tropicsoft dot com --- (In reply to Jonathan Wakely from comment #5) And as has been documented forever, the way to get diagnostics for GNU extensions that contradict the ISO standard is the -pedantic switch: https://gcc.gnu.org/onlinedocs/gcc-4.9.2/gcc/Warning-Options.html#index- pedantic-279 There is no bug here. So the GNU extension in this case is that the programmer does not have to pass an argument when a variadic parameter is used in a macro ? That would not even bother me if there were a compiler flag which allowed it. But you appear to be telling me that this non-C++ is by default. OK, how do I tell gcc to actually follow the C++ standard ? Do I pass '-pedantic' for that ? I realize gcc is used by many programmers and is loath to change the way it has done things so as not to upset long-time users of the compiler. Nonetheless I am going to suggest that the default should always be conformance to the C++ standard, and that GNU extensions should be turned on with some compiler option.
[Bug c++/65547] Gcc not giving preprocessor error for invalid invocation of variadic macro
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65547 --- Comment #8 from Jonathan Wakely redi at gcc dot gnu.org --- (In reply to Edward Diener from comment #7) So the GNU extension in this case is that the programmer does not have to pass an argument when a variadic parameter is used in a macro ? Yes, as documented at https://gcc.gnu.org/onlinedocs/gcc-4.9.2/gcc/Variadic-Macros.html That would not even bother me if there were a compiler flag which allowed it. But you appear to be telling me that this non-C++ is by default. Yes, did you read the link I gave explaining the semantics of -pedantic? OK, how do I tell gcc to actually follow the C++ standard ? Do I pass '-pedantic' for that ? Yes, as I already said in comment 5, in the text you quoted. And to make it an error not a warning use -pedantic-errors. I realize gcc is used by many programmers and is loath to change the way it has done things so as not to upset long-time users of the compiler. Nonetheless I am going to suggest that the default should always be conformance to the C++ standard, and that GNU extensions should be turned on with some compiler option. As it states in the manual (again, see the link in comment 5), if you write valid ISO C++ programs using variadic macros then you will never notice this extension. Your valid uses are accepted as required, and as an extension some invalid ones are also silently accepted unless you use -pedantic. This is consistent, well-documented, and what many users expect and prefer. If you prefer something different, there's an option for that.
[Bug c++/65547] Gcc not giving preprocessor error for invalid invocation of variadic macro
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65547 --- Comment #3 from Edward Diener eldlistmailingz at tropicsoft dot com --- Where do you get the idea that the standard doesn't require an error, it requires a diagnostic message ? It clearly is a violation of the C++11 standard according to the section and paragraph I cited in my bug report.
[Bug c++/65547] Gcc not giving preprocessor error for invalid invocation of variadic macro
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65547 Jonathan Wakely redi at gcc dot gnu.org changed: What|Removed |Added Status|UNCONFIRMED |RESOLVED Resolution|--- |INVALID --- Comment #2 from Jonathan Wakely redi at gcc dot gnu.org --- (In reply to Edward Diener from comment #0) Instead gcc outputs the warning: warning: ISO C99 requires rest arguments to be used. But since the compile is done with C++11 support the reference should be to the C++11 standard Already fixed for GCC 5. v.c:2:21: warning: ISO C++11 requires at least one argument for the ... in a variadic macro and an error should occur. That an error does not occur I consider a bug. No, the standard doesn't require an error, it requires a diagnostic message. If a program contains a violation of any diagnosable rule or an occurrence of a construct described in this Standard as “conditionally-supported” when the implementation does not support that construct, a conforming implementation shall issue at least one diagnostic message. A warning is a diagnostic message, ergo there is no bug. As Andrew pointed out, use -pedantic-errors (or -Werror=pedantic) if you want to turn such warnings into errors.
[Bug c++/65547] Gcc not giving preprocessor error for invalid invocation of variadic macro
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65547 --- Comment #1 from Andrew Pinski pinskia at gcc dot gnu.org --- Try -pedantic-error instead.