This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: conditional assigments vs. "may be used uninitialized"
- From: "Andrew Pinski" <pinskia at gmail dot com>
- To: "Hallvard B Furuseth" <h dot b dot furuseth at usit dot uio dot no>
- Cc: gcc at gcc dot gnu dot org
- Date: Wed, 22 Oct 2008 13:02:26 -0700
- Subject: Re: conditional assigments vs. "may be used uninitialized"
- References: <hbf.20081022dxqm@bombur.uio.no>
On Wed, Oct 22, 2008 at 12:57 PM, Hallvard B Furuseth
<h.b.furuseth@usit.uio.no> wrote:
> Info node (gcc)Warning Options mentions that gcc warns about
>
> int save_y;
> if (change_y) save_y = y, y = new_y;
> ...
> if (change_y) y = save_y;
>
> However that's not always true, so it looks like gcc does have
> the smarts to drop the warning. Could that be improved?
>
> gcc -W -O does not warn about this snippet, but it does warn with
> -DMACRO or -O2. So it looks like the information that this code
> is safe is available but not used.
Well the reason it is not warning in the -UMACRO case is because jump
threading optimization has happened and removes one of the
if(change_y) condition.
Thanks,
Andrew Pinski