This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: conditional assigments vs. "may be used uninitialized"


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]