http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48026

           Summary: #pragma optimize ignored for C++
           Product: gcc
           Version: 4.5.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassig...@gcc.gnu.org
        ReportedBy: s...@robots.org.uk


#pragma optimize seems to be ignored for C++.


=== Makefile ===
all: opt_c.s opt_cxx.s
.PHONY: all

opt_c.s: opt.c
    gcc -S -o $@ -O2 $<

opt_cxx.s: opt.c
    g++ -S -o $@ -O2 $<

clean:
    rm -f *.s
.PHONY: clean

=== opt.c ===
#pragma GCC optimize ("O0")

#ifdef __OPTIMIZE__
#error help!
#endif

int main () {
    int i;
    for (i = 0; i < 2000000000; ++i)
        ;
}

=== test output ===
$ make -k
gcc -S -o opt_c.s -O2 opt.c
g++ -S -o opt_cxx.s -O2 opt.c
opt.c:4:2: error: #error help!
make: *** [opt_cxx.s] Error 1
make: Target `all' not remade because of errors.

Reply via email to