[llvm-bugs] [Bug 40665] New: __VA_OPT__ is only supported by Clang's preprocessor in C++2a mode but GCC seems to support it in all language modes
via llvm-bugs
llvm-bugs at lists.llvm.org
Fri Feb 8 08:56:57 PST 2019
https://bugs.llvm.org/show_bug.cgi?id=40665
Bug ID: 40665
Summary: __VA_OPT__ is only supported by Clang's preprocessor
in C++2a mode but GCC seems to support it in all
language modes
Product: clang
Version: trunk
Hardware: PC
OS: All
Status: NEW
Severity: enhancement
Priority: P
Component: Frontend
Assignee: unassignedclangbugs at nondot.org
Reporter: dan at su-root.co.uk
CC: llvm-bugs at lists.llvm.org, neeilans at live.com,
richard-llvm at metafoo.co.uk
The attached program can be compiled by GCC 8.2.1 in various language modes
```
gcc -x c -std=gnu89 varargs.c
gcc -x c -std=gnu99 varargs.c
gcc -x c -std=gnu11 varargs.c
gcc -x c -std=gnu89 varargs.c
gcc -x c -std=gnu99 varargs.c
gcc -x c -std=gnu11 varargs.c
g++ -x c++ -std=c++98 varargs.c
g++ -x c++ -std=c++11 varargs.c
g++ -x c++ -std=c++14 varargs.c
g++ -x c++ -std=c++17 varargs.c
g++ -x c++ -std=c++2a varargs.c
g++ -x c++ -std=gnu++98 varargs.c
g++ -x c++ -std=gnu++11 varargs.c
g++ -x c++ -std=gnu++14 varargs.c
g++ -x c++ -std=gnu++17 varargs.c
g++ -x c++ -std=gnu++2a varargs.c
```
but Clang fails to compile it because the `__VA_OPT__()` macro does not get
expanded for all of the above language variants except for `c++2a` and
`gnu++2a`.
I believe `__VA_OPT_()` is a C++2a feature so Clang is probably more correct
here.
However according to https://gcc.gnu.org/onlinedocs/cpp/Variadic-Macros.html
`__VA_OPT_()` is supposed to be available for GNU C and GNU C++ too so we
probably ought to enable it when we are compiling for the GNU language variants
`-std=gnu*`.
The fact that GCC allows `__VA_OPT__()` in non-GNU language variants that isn't
`c++2a` seems like a bug but I am not currently in a position to report it.
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20190208/32862e6d/attachment.html>
More information about the llvm-bugs
mailing list