This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: Optimization attributes const vs. pure
- From: Johannes Bauer <dfnsonfsduifb at gmx dot de>
- To: gcc-help at gcc dot gnu dot org
- Cc: keisial at gmail dot com
- Date: Mon, 28 May 2012 16:49:59 +0200
- Subject: Re: Optimization attributes const vs. pure
- References: <4FC37103.9000300@gmx.de> <4FC38E4E.6090908@gmail.com>
On 28.05.2012 16:40, Ángel González wrote:
> On 28/05/12 14:35, Johannes Bauer wrote:
>> So "pure" would be the perfect fit: Global memory is read but not
>> modified (which is also asserted by passing the arguments as "const").
>> Why is gcc then not doing the optimization that I'd want it to perform?
> I have no idea.
> I wondered if it feared fprintf changing global variables on which
> intcmp() depended,
> so I modified it to create the following program, where there is no
> side-effect.
> But it still exhibits the same behavior (intcmp called 100 times if
> pure, 1 if const).
Thank you for trying it out... good to get confirmation that this isn't
just the case with my arch/gcc combination. Would you mind sharing which
platform/gcc version you've tried it out with?
Best regards,
Johannes