Re: variable ‘something’ set but not used [-Wunused-but-set-variable]

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

 



Hi all,
I don't know why I don't receive emails from gcc-help correctly.
In the archive I saw Axel Freyn replied this:


Gcc is right, the warning is appropriate.
gcc tells you that fullpath_length is not necessary, because while you
ASSIGN a value to it ("variable ... set"), you NEVER READ that value
("but not used").
And in your example code: Imagine we would simply remove
fullpath_length, and replace the last line by "strlen(fullpath);", then
your code would behave exactly as before. 
So why do you have this variable fullpath_length? if you don't want that kind of warning, compile with the flag
-Wno-unused-but-set-variable 

Thanks Axel, I understand. I commented fullpath_length = strlen(fullpath); 
and there is no problem with that

Thanks 





// Naderan *Mahmood;


----- Original Message -----
From: Andrew Haley <aph@xxxxxxxxxx>
To: Mahmood Naderan <nt_mahmood@xxxxxxxxx>
Cc: gcc <gcc-help@xxxxxxxxxxx>
Sent: Tuesday, July 12, 2011 10:43 PM
Subject: Re: variable ‘something’ set but not used [-Wunused-but-set-variable]

On 07/12/2011 07:12 PM, Mahmood Naderan wrote:
>> The message is correct.  fullpath_length is set, but not used.
>  
> Hi
> What is this then
> 
>      fullpath_length = strlen(fullpath);     // variable is used here
> 
> isn't a usage of fullpath_length?

No, it's not.  It's a set of fullpath_length.

Andrew.




[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