| Summary: | [3.4 Regression] [unit-at-a-time] __attribute__((constructor)) broken in C++ | ||
|---|---|---|---|
| Product: | gcc | Reporter: | Andris Pavenis <andris.pavenis> |
| Component: | c++ | Assignee: | Mark Mitchell <mark> |
| Status: | RESOLVED FIXED | ||
| Severity: | normal | CC: | flash, gcc-bugs, hubicka, sjames |
| Priority: | P2 | Keywords: | wrong-code |
| Version: | 3.4.1 | ||
| Target Milestone: | 3.4.2 | ||
| Host: | Target: | ||
| Build: | Known to work: | 3.3.3, 4.0.0 | |
| Known to fail: | 3.4.0 | Last reconfirmed: | 2004-07-27 02:37:13 |
__attribute__((constructor)) doesn't work in C++ for both gcc-3.4.1 and gcc-3.5.0 20040725 when optimization level -O2 is being used. All seems to work Ok with gcc-3.3.4. -------------------- bug.cc ---------------------- #include <stdio.h> void hello (void) __attribute__ ((constructor)); void hello (void) { printf ("Hello world\n"); } int main (void) { return 0; } --------------------------------------------------- g++ -O2 bug.cc -o bug ./bug works with gcc-3.3.4, but not with gcc-3.4.1 and 3.5.0 20040725 (Initially bug were reported for target i586-pc-msdosdjgpp)