https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84628
--- Comment #3 from Jay <jay.krell at cornell dot edu> --- The original case said something about "localalias" in the error, so aliases don't seem to address it. I can dig that up probably. Shouldn't it warn for: if (0) banned_function() ? I believe we want it to. You know, strive for equal warnings/errors w/ or w/o optimization, but I know that is impossible in general, because optimization==analysis. I believe attribute(error) should be like pragma poison except: - easier to implement the deprecated function - can provide custom error - works with C++ overloads -- attach attribute to full declaration, not just identifier But yeah, another option is to optimize a little less, on a case by case basis. Or actually remove the attribute, or don't warn, if the compiler essentially introduced the use.