This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: Need some clarification about optimization flags, what "exactly" does -O1 do?
- From: Andrew Haley <aph at redhat dot com>
- To: Andrzej Giniewicz <gginiu at gmail dot com>
- Cc: "gcc-help at gcc dot gnu dot org" <gcc-help at gcc dot gnu dot org>
- Date: Thu, 27 Nov 2008 11:41:40 +0000
- Subject: Re: Need some clarification about optimization flags, what "exactly" does -O1 do?
- References: <f6d5b6a20811270221jce1e76al39ceded1a3508a81@mail.gmail.com> <492E830A.3070607@redhat.com> <f6d5b6a20811270333h3764c9a5jee3dbd95e6e76206@mail.gmail.com>
Andrzej Giniewicz wrote:
>> What does the declaration of IndexType look like?
>
> nothing special:
>
> enum IndexType {
> IT_16BIT,
> IT_32BIT
> };
>
>> The bug is probably in your app, not in gcc.
>> I think you'd be much better off fixing the bug than trying to
>> discover which optimization pass it breaks.
>
> not quite my app just app I try to build, i.e. developer seems to not
> have gcc 4.3 yet and I am just trying to get it on :) To be more
> precise - the value that is defined as:
>
> ... ? HardwareIndexBuffer::IT_32BIT : HardwareIndexBuffer::IT_16BIT
>
> is then checked with:
>
> switch (mIndexType)
> {
> case IT_16BIT:
> mIndexSize = sizeof(unsigned short);
> break;
> case IT_32BIT:
> mIndexSize = sizeof(unsigned int);
> break;
> }
>
> but it don't trigger any of those in anything more than -O0 (if I add
> default with cerr<< it is triggered) and works on -O0... I didn't
> thought such funny thing can be caused by some bug where code is quite
> easy, simple switch on enumerated value that is set to one of two and
> not used/changed anywhere else...
Yeah, but that bug almost certainly isn't in the code you're looking at.
I've recently seen a bug that was triggered by -O in an enum where the
declaration was:
enum Cell {
Cell_0
};
and gcc quite correctly assumed that a Cell could only have one value.
I'm not saying I'm absolutely certain this isn't a bug in gcc. It's just
that it probably isn't.
Andrew.