This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: Authoritative answer wanted: "-g -O1" vs. "-O1"
- From: David Brown <david at westcontrol dot com>
- To: Ian Lance Taylor <iant at google dot com>
- Cc: Gene Smith <gds at chartertn dot net>, <gcc-help at gcc dot gnu dot org>
- Date: Tue, 18 Jun 2013 20:48:22 +0200
- Subject: Re: Authoritative answer wanted: "-g -O1" vs. "-O1"
- References: <kpoqoj$ebj$1 at ger dot gmane dot org> <CAKOQZ8zJ9Rn3xOS1=Co+Rzrjbrpt7=8u=TCR+4Qiz-ZVbuzKBA at mail dot gmail dot com> <51C07046 dot 3090005 at westcontrol dot com> <CAKOQZ8ywyMTaJDr-TRbOsSOOT_mCQPUQHAeNYPXzR8eJwwnFvA at mail dot gmail dot com>
On 18/06/13 18:32, Ian Lance Taylor wrote:
> On Tue, Jun 18, 2013 at 7:35 AM, David Brown <david@westcontrol.com> wrote:
>>
>> I did not think that was the case. As I understood it, "-g" /may/ cause
>> to the code to improve debugging. I can't say that I have ever noticed
>> any code changes, but I've always assumed it is possible especially with
>> more advanced optimisations.
>>
>> I certainly don't see anything in the documentation that suggests "-g"
>> cannot change the code - only that "-g -O" will generate optimised and
>> debugable code (though possibly with confusing debugging).
>
> That turns out not to be the case. It always been a strict rule with
> GCC that -g does not affect code generation.
>
> What the OP is describing is a serious bug.
>
> Ian
>
Thanks for that information. I think it is a useful feature that
enabling debugging does not affect the generated code, but I didn't
realise gcc was strict about it.
David