https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71003
Bug ID: 71003
Summary: __extension__ silences pedwarn for "\e" in C but not
in C++
Product: gcc
Version: 6.0
Status: UNCONFIRMED
Keywords: diagnostic
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: egall at gwmail dot gwu.edu
Target Milestone: ---
Host: i386-apple-darwin9.8.0
Target: i386-apple-darwin9.8.0
Build: i386-apple-darwin9.8.0
Say I have the following file:
$ cat __extension__.c
const char *str0 = "\e";
const char *str1 = __extension__ "\e";
When I try to compile it with gcc, everything works as expected:
$ /usr/local/bin/gcc -pedantic -c __extension__.c
__extension__.c:1:20: warning: non-ISO-standard escape sequence, '\e'
const char *str0 = "\e";
^~~~
i.e., it only warns on the string where I left off the __extension__.
However, when I try to compile it with g++, it warns on both strings:
$ /usr/local/bin/g++ -pedantic -c __extension__.c
__extension__.c:1:20: warning: non-ISO-standard escape sequence, '\e'
const char *str0 = "\e";
^~~~
__extension__.c:2:34: warning: non-ISO-standard escape sequence, '\e'
const char *str1 = __extension__ "\e";
^~~~
This behavior is inconsistent. I would expect the warning for the string with
__extension__ to be silenced in both cases, not just in C.
g++ version info:
$ /usr/local/bin/g++ -v
Using built-in specs.
COLLECT_GCC=/usr/local/bin/g++
COLLECT_LTO_WRAPPER=/usr/local/libexec/gcc/i386-apple-darwin9.8.0/7.0.0/lto-wrapper
Target: i386-apple-darwin9.8.0
Configured with: ../configure --disable-werror
--enable-languages=c,c++,lto,objc,obj-c++ --enable-stage1-checking=release -C
--with-system-libunwind --enable-secureplt --enable-frame-pointer
--enable-version-specific-runtime-libs --enable-assert --enable-fat
--enable-portable-binary --enable-browser-plugin --enable-gconf-peer
--enable-libgcj-debug --enable-gc-debug --enable-interpreter
--enable-aot-compile-rpm --enable-java-home --with-x --enable-collections
--enable-gstreamer-peer --enable-xmlj --enable-qt-peer --enable-debug
--enable-local-sockets --without-isl --enable-objc-gc --enable-maintainer-mode
--enable-host-shared CC=/usr/local/bin/gcc CXX=/usr/local/bin/g++
AUTOCONF=/usr/local/bin/autoconf AUTOHEADER=/usr/local/bin/autoheader
AUTOM4TE=/usr/local/bin/autom4te AUTORECONF=/usr/local/bin/autoreconf
AUTOSCAN=/usr/local/bin/autoscan AUTOUPDATE=/usr/local/bin/autoupdate
IFNAMES=/usr/local/bin/ifnames
Thread model: posix
gcc version 7.0.0 20160426 (experimental) (GCC)