https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100685
--- Comment #4 from Martin Sebor <msebor at gcc dot gnu.org> --- Thanks. I belatedly realized that the test case didn't reproduce the problem I was seeing. The one below demonstrates that the -O1 option does override the -O2 set earlier. Sorry for the noise! $ cat pr100685.c && gcc -O2 -S -Wall -fdump-tree-optimized=/dev/stdout pr100685.c #pragma GCC optimize ("2") int f (void) { char s[] = "abc"; return __builtin_strlen (s); // folded to 3 (good) } #pragma GCC push_options #pragma GCC optimize ("1") int g (void) { char s[] = "abc"; return __builtin_strlen (s); // not folded and shouldn't be } ;; Function f (f, funcdef_no=0, decl_uid=1943, cgraph_uid=1, symbol_order=0) __attribute__((optimize ("2"))) int f () { <bb 2> [local count: 1073741824]: return 3; } ;; Function g (g, funcdef_no=1, decl_uid=1947, cgraph_uid=2, symbol_order=1) __attribute__((optimize ("2", "1"))) int g () { char s[4]; long unsigned int _1; int _4; <bb 2> [local count: 1073741824]: s = "abc"; _1 = __builtin_strlen (&s); _4 = (int) _1; s ={v} {CLOBBER}; return _4; }