Bug 25810 - spurious warning about unused function return
Summary: spurious warning about unused function return
Status: RESOLVED DUPLICATE of bug 24900
Alias: None
Product: gcc
Classification: Unclassified
Component: c (show other bugs)
Version: 4.1.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-01-16 14:58 UTC by Andy Wingo
Modified: 2006-01-16 15:30 UTC (History)
3 users (show)

See Also:
Host: i386-redhat-linux
Target: i386-redhat-linux
Build: i386-redhat-linux
Known to work:
Known to fail:
Last reconfirmed:


Attachments
short test case to show problem -- preprocessed (216 bytes, text/plain)
2006-01-16 15:02 UTC, Andy Wingo
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Andy Wingo 2006-01-16 14:58:42 UTC
The attached file warns about an unused function return value, when the non-bugs section suggests that unused return values are quite fine.
Comment 1 Andy Wingo 2006-01-16 15:02:17 UTC
Created attachment 10654 [details]
short test case to show problem -- preprocessed

Compiler output:

[wingo@fakesink ~]$ gcc -v -save-temps -Wall -o test test.c
Using built-in specs.
Target: i386-redhat-linux
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-libgcj-multifile --enable-languages=c,c++,objc,obj-c++,java,fortran,ada --enable-java-awt=gtk --disable-dssi --with-java-home=/usr/lib/jvm/java-1.4.2-gcj-1.4.2.0/jre --host=i386-redhat-linux
Thread model: posix
gcc version 4.1.0 20060106 (Red Hat 4.1.0-0.14)
 /usr/libexec/gcc/i386-redhat-linux/4.1.0/cc1 -E -quiet -v test.c -Wall -fpch-preprocess -o test.i
ignoring nonexistent directory "/usr/lib/gcc/i386-redhat-linux/4.1.0/../../../../i386-redhat-linux/include"
#include "..." search starts here:
#include <...> search starts here:
 /usr/local/include
 /usr/lib/gcc/i386-redhat-linux/4.1.0/include
 /usr/include
End of search list.
 /usr/libexec/gcc/i386-redhat-linux/4.1.0/cc1 -fpreprocessed test.i -quiet -dumpbase test.c -auxbase test -Wall -version -o test.s
GNU C version 4.1.0 20060106 (Red Hat 4.1.0-0.14) (i386-redhat-linux)
	compiled by GNU C version 4.1.0 20060106 (Red Hat 4.1.0-0.14).
GGC heuristics: --param ggc-min-expand=64 --param ggc-min-heapsize=64435
Compiler executable checksum: 56e51ec7541d93cee9e835a9348da767
test.c: In function ‘main’:
test.c:33: warning: value computed is not used
 as -V -Qy -o test.o test.s
GNU assembler version 2.16.91.0.5 (i386-redhat-linux) using BFD version 2.16.91.0.5 20051219
 /usr/libexec/gcc/i386-redhat-linux/4.1.0/collect2 --eh-frame-hdr -m elf_i386 -dynamic-linker /lib/ld-linux.so.2 -o test /usr/lib/gcc/i386-redhat-linux/4.1.0/../../../crt1.o /usr/lib/gcc/i386-redhat-linux/4.1.0/../../../crti.o /usr/lib/gcc/i386-redhat-linux/4.1.0/crtbegin.o -L/usr/lib/gcc/i386-redhat-linux/4.1.0 -L/usr/lib/gcc/i386-redhat-linux/4.1.0 -L/usr/lib/gcc/i386-redhat-linux/4.1.0/../../.. test.o -lgcc --as-needed -lgcc_s --no-as-needed -lc -lgcc --as-needed -lgcc_s --no-as-needed /usr/lib/gcc/i386-redhat-linux/4.1.0/crtend.o /usr/lib/gcc/i386-redhat-linux/4.1.0/../../../crtn.o
Comment 2 Andy Wingo 2006-01-16 15:07:35 UTC
Just for clarity, here is the warning:

test.c: In function ‘main’:
test.c:33: warning: value computed is not used

The line corresponding to 33 in the preprocessed file:

    (void*)data_ref((data*)d);

data_ref is not declared as pure or const. It seems to be the cast that is causing the warning. The real-world case that causes this warning to be an issue are things like this, from GStreamer:

#define	gst_buffer_ref(buf) \
  GST_BUFFER_CAST (gst_mini_object_ref (GST_MINI_OBJECT (buf)))
Comment 3 Andrew Pinski 2006-01-16 15:30:51 UTC
This is actually not a bug.  This is also a dup of bug 24900.

*** This bug has been marked as a duplicate of 24900 ***