RE: gcc compiler warnings

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

 



Fumble fingers ...  I meant

	oldval = *ptr++;

-----Original Message-----
From: gcc-help-owner@xxxxxxxxxxx [mailto:gcc-help-owner@xxxxxxxxxxx] On Behalf Of Jonathan Saxton
Sent: Wednesday 19 May 2010 10:31
To: gcc-help
Subject: RE: gcc compiler warnings

Your compiler speaks the truth.  You are not using the computed value.

What do you think

	*ptr++;

actually does?  It fetches the value stored at *ptr, then increments ptr.  Where do you use the value?

As Andrew pointed out, perhaps you just wanted to increment the pointer without actually fetching the thing addressed by the pointer.  If that is the case then you could just say:

	oldval = ptr++;	// Make local copy and scroll 1 ahead in ring buffer



-----Original Message-----
From: gcc-help-owner@xxxxxxxxxxx [mailto:gcc-help-owner@xxxxxxxxxxx] On Behalf Of lee
Sent: Wednesday 19 May 2010 05:42
To: gcc-help
Subject: gcc compiler warnings

Hi simple qeuery ...

why does gcc give a warning:   warning: value computed is not used

for...  ptr++;

when the value is actually used!

code segment...
do {
        oldval=*ptr;//make local copy
       
        *ptr++; // scroll 1 ahead in ring buffer
        if(isHeader(&oldval) && cntnumber > 1 ) //skip first header 
word. check for header words inside data
            break;
        cntnumber += 1;
    }while(  !isTrailer( &oldval ) && cntnumber < totalchannels  ); // 
copy until the trailer

Regards
L



[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