[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Optimization breaks program
From: |
Robert Heller |
Subject: |
Re: Optimization breaks program |
Date: |
Wed, 28 Apr 2004 13:03:35 +0200 |
Paul Schneider <paulibaer@uboot.com>,
In a message on Wed, 28 Apr 2004 12:13:43 +0200, wrote :
PS> With optimization turned to O1, O2, or O3, I get segfaults with my
PS> program. With no optimization everything runs fine. Is this a common
PS> thing to happen?
Generally not. Usually there is some *minor* programming error.
Common ones:
Uninitialized variables (referenced before being set, often
pointers or indexes).
Sometimes the declaration of large (or just not trivial sized)
arrays as 'automatic' (local off the stack). Change these to 'static'
storage class (still local).
There are *rare* cases where optimization breaks the code. These might
be considered actual compiler bugs.
PS>
PS> Best,
PS>
PS> Paul Schneider
PS>
PS>
\/
Robert Heller ||InterNet: heller@cs.umass.edu
http://vis-www.cs.umass.edu/~heller || heller@deepsoft.com
http://www.deepsoft.com /\FidoNet: 1:321/153