This is the mail archive of the gcc-help@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: Warnings with -Og - gcc 4.8


Jeff Law <law@redhat.com> writes:

| On 03/05/2013 12:04 PM, Lars Gullik Bjønnes wrote:
>> Jeffrey Walton <noloader@gmail.com> writes:
>>
>> | On Tue, Mar 5, 2013 at 1:41 PM, Lars Gullik Bjønnes
>> | <larsbj@gullik.org> wrote:
>>>> I get a lot of warnings with -Og and gcc from trunk.
>>>> I do not get these warnings with any other warning level.
>>>>
>>>> This is a reduced example:
>>>> ----------
>>>> int foo(void);
>>>>
>>>> int failing(void)
>>>> {
>>>>          int r;
>>>>          unsigned int i;
>>>>          struct h * p[3];
>>>>
>>>>          for (i = 0; i < sizeof(p) / sizeof(p[0]); ++i) {
>>>>                  r = foo();
>>>>                  if (r != 0)
>>>>                          break;
>>>>          }
>>>>          return r >= 0;
>>>> }
>>>> -----------
>>>>
>>>> Compile with: gcc -Og -Wall -c fil.c
>>>>
>>>> gcc --version
>>>> gcc (GCC) 4.8.0 20130304 (experimental)
>>>>
>>>> Should I create a bug on this, or will someone else handle that?
>> | What warnings?
>>
>> $ gcc -Og -Wall -c fil.c
>> fil.c: In function ‘failing’:
>> fil.c:14:11: warning: ‘r’ may be used uninitialized in this function
>> [-Wmaybe-uninitialized]
>>    return r >= 0;
>
| Without the optimizer enabled, GCC does not do the analysis to prove
| the loop always executes and thus does not know it can eliminate the
| edge from the entry block to the return block with its associated
| uninitialized use.

I see that I have a mistake in my first post, I meant to say:

  I do not see this with any other _optimization_ level.

I do not get this warning with -O0, nor with -O1, only with -Og.

-- 
	Lgb


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