[Bug c/25810] New: spurious warning about unused function return

2006-01-16 Thread wingo at pobox dot com
The attached file warns about an unused function return value, when the
non-bugs section suggests that unused return values are quite fine.


-- 
   Summary: spurious warning about unused function return
   Product: gcc
   Version: 4.1.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: wingo at pobox dot com
 GCC build triplet: i386-redhat-linux
  GCC host triplet: i386-redhat-linux
GCC target triplet: i386-redhat-linux


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25810



[Bug c/25810] spurious warning about unused function return

2006-01-16 Thread wingo at pobox dot com


--- Comment #1 from wingo at pobox dot com  2006-01-16 15:02 ---
Created an attachment (id=10654)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=10654&action=view)
short test case to show problem -- preprocessed

Compiler output:

[EMAIL PROTECTED] ~]$ 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


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25810



[Bug c/25810] spurious warning about unused function return

2006-01-16 Thread wingo at pobox dot com


--- Comment #2 from wingo at pobox dot com  2006-01-16 15:07 ---
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)))


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25810