How to force gcc to report a warning/error

Ian Lance Taylor iant@google.com
Wed Oct 27 07:32:00 GMT 2010


Thomas Martitz <thomas.martitz@student.htw-berlin.de> writes:

> On 26.10.2010 15:37, Ian Lance Taylor wrote:
>> Thomas Martitz<thomas.martitz@student.htw-berlin.de>  writes:
>>
>>> Assuming min() is a macro or a pure or inline function,  shouldn't gcc issue a "statement without effect" warning because it has no side effects?
>> Yes.  But that will only happen if min is indeed given the pure
>> attribute.
>>
>> Ian
>
> So not if gcc's heuristics detect the pureness?

You are correct that if gcc can detect that the function is pure, that
that is equivalent.

However, that can only happen if gcc can see the function body, which I
assume is not the case here.  If gcc can see the body of the min
function, then it will almost certainly inline it when optimizing.

Ian



More information about the Gcc-help mailing list