This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/30496] New: Compilation errors when compiled with optimization flags
- From: "csandu4096 at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 18 Jan 2007 10:49:30 -0000
- Subject: [Bug c++/30496] New: Compilation errors when compiled with optimization flags
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
When I compile the following code with optimization flags (O1, O2, O3, Os) I
get compilation errors. If the code is compiled without optimizations (-g, -O0)
then everything is ok.
Error.cpp :
#include <libintl.h>
#define _(x) gettext(x)
typedef struct
{
int code;
const char* p_str;
} ErrorStr;
static ErrorStr g_errorStrTab[] =
{
{ 1, _("Success") },
{ 2, _("Invalid error code") },
{ 3, _("Invalid argument") },
{ 4, _("Convertion error") }
};
The platform is : Debian 2.2 Potato, glibc 2.1.3
The output of "gcc -v -save-temps -Os -c Error.cpp" is :
Using built-in specs.
Target: i686-pc-linux-gnu
Configured with: ./configure --enable-languages=c,c++
Thread model: posix
gcc version 4.1.1
/usr/local/libexec/gcc/i686-pc-linux-gnu/4.1.1/cc1plus -E -quiet -v
-D_GNU_SOURCE Error.cpp -mtune=pentiumpro -Os -fpch-preprocess -o Erro
r.ii
ignoring nonexistent directory "NONE/include"
ignoring nonexistent directory
"/usr/local/lib/gcc/i686-pc-linux-gnu/4.1.1/../../../../i686-pc-linux-gnu/include"
#include "..." search starts here:
#include <...> search starts here:
/usr/local/lib/gcc/i686-pc-linux-gnu/4.1.1/../../../../include/c++/4.1.1
/usr/local/lib/gcc/i686-pc-linux-gnu/4.1.1/../../../../include/c++/4.1.1/i686-pc-linux-gnu
/usr/local/lib/gcc/i686-pc-linux-gnu/4.1.1/../../../../include/c++/4.1.1/backward
/usr/local/include
/usr/local/lib/gcc/i686-pc-linux-gnu/4.1.1/include
/usr/include
End of search list.
/usr/local/libexec/gcc/i686-pc-linux-gnu/4.1.1/cc1plus -fpreprocessed Error.ii
-quiet -dumpbase Error.cpp -mtune=pentiumpro -auxbase Error
-Os -version -o Error.s
GNU C++ version 4.1.1 (i686-pc-linux-gnu)
compiled by GNU C version 4.1.1.
GGC heuristics: --param ggc-min-expand=38 --param ggc-min-heapsize=15901
Compiler executable checksum: 6b1156c38beeebd4aa05553feb32ed24
Error.cpp:13: error: statement-expressions are allowed only inside functions
Error.cpp:14: error: statement-expressions are allowed only inside functions
Error.cpp:14: error: redefinition of 'char* __result'
Error.cpp:13: error: 'char* __result' previously declared here
Error.cpp:14: error: redefinition of 'char* __translation__'
Error.cpp:13: error: 'char* __translation__' previously declared here
Error.cpp:14: error: redefinition of 'int __catalog_counter__'
Error.cpp:13: error: 'int __catalog_counter__' previously declared here
Error.cpp:15: error: statement-expressions are allowed only inside functions
Error.cpp:15: error: redefinition of 'char* __result'
Error.cpp:13: error: 'char* __result' previously declared here
Error.cpp:15: error: redefinition of 'char* __translation__'
Error.cpp:13: error: 'char* __translation__' previously declared here
Error.cpp:15: error: redefinition of 'int __catalog_counter__'
Error.cpp:13: error: 'int __catalog_counter__' previously declared here
Error.cpp:16: error: statement-expressions are allowed only inside functions
Error.cpp:16: error: redefinition of 'char* __result'
Error.cpp:13: error: 'char* __result' previously declared here
Error.cpp:16: error: redefinition of 'char* __translation__'
Error.cpp:13: error: 'char* __translation__' previously declared here
Error.cpp:16: error: redefinition of 'int __catalog_counter__'
Error.cpp:13: error: 'int __catalog_counter__' previously declared here
--
Summary: Compilation errors when compiled with optimization flags
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: csandu4096 at gmail dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30496