#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.
Confirmed, this is most likely the same issue as PR 41201.
(In reply to comment #1) > Confirmed, this is most likely the same issue as PR 41201. Well, not completely the same. The original issue reported in PR 41201 is about defining the macros, but the possible fix in http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41201#c6 is about this bug.
Still existent in 4.8.4
This is probably because the preprocessor runs before the #pragmas are handled. If so, this is the same issue as for #pragma GCC diagnostics in C++ (PR53431).
Created attachment 56811 [details] Proposed patch against trunk Here is a proposed patch against trunk, which includes a fix for PR preprocessor/87299 (#pragma GCC target).
(In reply to Gwenole Beauchesne from comment #5) > Created attachment 56811 [details] > Proposed patch against trunk > > Here is a proposed patch against trunk, which includes a fix for PR > preprocessor/87299 (#pragma GCC target). Could you send this to the mailing list if it's still relevant? Thanks. (https://gcc.gnu.org/contribute.html)
*** Bug 114370 has been marked as a duplicate of this bug. ***