[Bug preprocessor/58844] [4.8 Regression] ICE with invalid use of ##
potswa at mac dot com
gcc-bugzilla@gcc.gnu.org
Tue Aug 12 08:05:00 GMT 2014
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=58844
--- Comment #11 from David Krauss <potswa at mac dot com> ---
On 2014–08–12, at 3:10 PM, jakub at gcc dot gnu.org <gcc-bugzilla@gcc.gnu.org>
wrote:
> Please see https://gcc.gnu.org/ml/gcc-patches/2009-04/msg01490.html for
> reasoning why gcc considers it valid.
That reasoning goes awry at “ISO C is silent about this possibility.” C and C++
both say,
> each instance of a ## preprocessing token in the replacement list (not from an argument) is deleted and the preceding preprocessing token is concatenated with the following preprocessing token.
This is unambiguous in that consecutive ## tokens get pasted; they can’t all be
operators. The spec also says, “The order of evaluation of ## operators is
unspecified,” which doesn’t seem like much of a constraint but it does suggest
that they are evaluated one-by-one.
The standard also says “If the result is not a valid preprocessing token, the
behavior is undefined,” so no diagnosis is required. However, there have been a
couple proposals to make it required, so it’s a very good idea. Even if the
user really meant them to be operators, it won’t be portable.
More information about the Gcc-bugs
mailing list