Re: how to ignore "X variable may be used uninitialized in this function"

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I suggest you check gcc man page to see each -W option you chose. I'm
using the test case proposed on documentation:

--- x ---

int f() {
       int i = i;
       return i;
}

int main() {
        f();
        return 0;
}

--- x ---

$ gcc -Wall -Wuninitialized -Winit-self -O1 c.c -o c
c.c: In function ‘f’:
c.c:11: warning: ‘i’ is used uninitialized in this function

$ gcc -Wall -Wuninitialized -O1 c.c -o c


--tm


On Thu, Jun 24, 2010 at 1:53 AM, smallboat <smallboatca@xxxxxxxxx> wrote:
> Thanks. But -Winit-self still does not remove this warning.
>
> This is the warnings I included in compiling:'
>
>  -Wall -Wbad-function-cast -Wcast-qual -Wchar-subscripts -Wcomment -Wdeprecated-declarations -Wdisabled-optimization -Wdiv-by-zero -Wendif-labels -Wformat -Wformat-extra-args -Wformat-nonliteral -Wformat-security -Wformat-y2k -Wimplicit -Wimplicit-function-declaration -Wimplicit-int -Wimport -Winline -Winvalid-pch -Wlong-long -Wmain -Wmissing-braces -Wmissing-declarations -Wmissing-format-attribute -Wmissing-noreturn -Wmissing-prototypes -Wmultichar -Wnested-externs -Wnonnull -Wparentheses -Wpointer-arith -Wreturn-type -Wsequence-point -Wshadow -Wsign-compare -Wstrict-aliasing -Wstrict-prototypes -Wswitch -Wswitch-default -Wswitch-enum -Wsystem-headers -Wtrigraphs -Wunknown-pragmas -Wunused -Wunused-function -Wunused-label -Wunused-value -Wunused-variable -Wwrite-strings -Wcast-align -Wno-pointer-sign -Wunused
>
> --- On Wed, 6/23/10, Tiago Maluta <tiago.maluta@xxxxxxxxx> wrote:
>
>> From: Tiago Maluta <tiago.maluta@xxxxxxxxx>
>> Subject: Re: how to ignore "X variable may be used uninitialized in this  function"
>> To: "smallboatca@xxxxxxxxx" <smallboatca@xxxxxxxxx>
>> Cc: gcc-help@xxxxxxxxxxx
>> Date: Wednesday, June 23, 2010, 9:30 PM
>> On Thu, Jun 24, 2010 at 12:59 AM, smallboatca@xxxxxxxxx
>> <smallboatca@xxxxxxxxx>
>> wrote:
>> >
>> > Hi,
>> >
>> > I got this "cond" may be used uninitialized in this
>> function waring in
>> > compiling my program.
>> >
>> > I used -Wuninitialized to ignore this warning, but it
>> does not work.
>> > Do you know which option (-W????) is for this  "X
>> variable may be used
>> > uninitialized in this function"? Thanks
>> >
>>
>> If you want _ignore_ this warning just omit -Winit-self
>>
>> --tm
>>
>
>
>
>



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux