https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83223
Bug ID: 83223 Summary: -fconserve-stack outlined code isn't dropped if it's logically unreachable Product: gcc Version: 7.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: george.burgess.iv at gmail dot com Target Milestone: --- GCC version: Reproed on godbolt's GCC trunk, 7.2, and 4.9. Test case (godbolt link, if you'd prefer: https://godbolt.org/g/zxhjPV): $ echo 'struct data { char foo[64]; }; void complain() __attribute__((warning("oh no!"))); void panic(const char *) __attribute__((noreturn, cold)); void *foo_real(void *, const void *); void bar(struct data *ptr) { char tmp[sizeof(ptr->foo)]; if (__builtin_object_size(ptr->foo, 0) >= sizeof(ptr->foo)) { foo_real(ptr->foo, tmp); } else { complain(); panic(""); } } __auto_type v = bar;' | gcc -x c -fconserve-stack -O2 - -o /dev/null -c <stdin>: In function ‘bar.part.0’: <stdin>:12:5: warning: call to ‘complain’ declared with attribute warning: oh no! It looks like the outlined part sticks around if `bar`'s address is taken. Normally, this isn't a problem. However, it can cause false-positives in code that uses the warning or error attributes (as shown above).