I'm afraid this is not quite what I mean. The issue is that __builtin_constant_p() is not tightly coupled with the knowledge of something actually being constant. So, you process code that looks (roughly) like: var = 1; if (something) cond = __builtin_constant_p(var); else { var = unknown_result(); cond = __builtin_constant_p(var); } if (cond) { d = y / var; } If cond is true, then var must be 1 (known to be constant), so GCC could optimize the expression (y / var) to (y / 1). I know this can be hard to track.