Sourc code for t.cpp: ------------------------------------------------ int mymain() { void *p = (void *)(struct {int i;} *)0; /* error - can't define a type in a cast */ return 0; }
------------------------------------------------ Expected Behaviour: ------------------------------------------------ t.cpp:3: error: ISO C++ forbids defining types within cast ------------------------------------------------ Actual Behaviour: ------------------------------------------------ t.cpp:3: warning: ISO C++ forbids defining types within cast ------------------------------------------------ t.ii generated with -save-temps option ------------------------------------------------ # 1 "t.cpp" # 1 "t.cpp" # 1 "<built-in>" # 1 "<command line>" # 1 "t.cpp" int mymain() { void *p = (void *)(struct {int i;} *)0; return 0; } ------------------------------------------------ Release: ------------------------------------------------ GCC Version: 3.2.0 ------------------------------------------------ Environment: System Type: ------------------------------------------------ Reading specs from /usr/libexec/gcc/darwin/ppc/3.3/specs Thread model: posix gcc version 3.3 20030304 (Apple Computer, Inc. build 1495) /usr/libexec/gcc/darwin/ppc/3.3/cc1plus -E -D__GNUG__=3 -quiet -v -D__GNUC__=3 -D__GNUC_MINOR__=3 -D__GNUC_PATCHLEVEL__=0 -D__APPLE_CC__=1495 -D__DYNAMIC__ /home/msadoghi/scenario/common/t.cpp -fPIC -std=iso9899:199409 -pedantic -D__private_extern__=extern t.ii cc1plus: warning: "-std=iso9899:199409" is valid for C/ObjC but not for C++ ignoring nonexistent directory "/usr/ppc-darwin/include" ignoring nonexistent directory "/Local/Library/Frameworks" #include "..." search starts here: #include <...> search starts here: /usr/include/gcc/darwin/3.3/c++ /usr/include/gcc/darwin/3.3/c++/ppc-darwin /usr/include/gcc/darwin/3.3/c++/backward /usr/local/include /usr/include/gcc/darwin/3.3 /usr/include End of search list. Framework search starts here: /System/Library/Frameworks /Library/Frameworks End of framework search list. /usr/libexec/gcc/darwin/ppc/3.3/cc1plus -fpreprocessed t.ii -fPIC -quiet -dumpbase t.cpp -auxbase t -pedantic -std=iso9899:199409 -version -D__private_extern__=extern -o t.s cc1plus: warning: "-std=iso9899:199409" is valid for C/ObjC but not for C++ GNU C++ version 3.3 20030304 (Apple Computer, Inc. build 1495) (ppc-darwin) compiled by GNU C version 3.3 20030304 (Apple Computer, Inc. build 1495). GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=131072 /home/msadoghi/scenario/common/t.cpp: In function `int mymain()': /home/msadoghi/scenario/common/t.cpp:3: warning: ISO C++ forbids defining types within cast /usr/libexec/gcc/darwin/ppc/as -arch ppc -o t.o t.s ------------------------------------------------ How-To-Repeat: ------------------------------------------------ g++ -v -save-temps -c -std=iso9899:199409 -pedantic t.cpp ------------------------------------------------ Note: ------------------------------------------------ This is a diagnostic test case. Compilation failure is expected on the strict mode, where type is defined in a cast. C++ ANSI Standard: "Types shall not be defined in casts in the strict mode." AIX, MACOS and LINUX all have a similar behaviors. ------------------------------------------------ -- Summary: Types shall not be defined in casts in the strict mode. Product: gcc Version: 3.2 Status: UNCONFIRMED Severity: normal Priority: P2 Component: c++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: msadoghi at ca dot ibm dot com CC: gcc-bugs at gcc dot gnu dot org http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20064