This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: how to ignore "X variable may be used uninitialized in this function"
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@yahoo.com> 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@gmail.com> wrote:
>
>> From: Tiago Maluta <tiago.maluta@gmail.com>
>> Subject: Re: how to ignore "X variable may be used uninitialized in this ?function"
>> To: "smallboatca@yahoo.com" <smallboatca@yahoo.com>
>> Cc: gcc-help@gcc.gnu.org
>> Date: Wednesday, June 23, 2010, 9:30 PM
>> On Thu, Jun 24, 2010 at 12:59 AM, smallboatca@yahoo.com
>> <smallboatca@yahoo.com>
>> 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
>>
>
>
>
>