<< Back to previous view

[PCC-40] pcc doesn't compile due to warn_unused_result after gcc-4.3.3 upgrade Created: 22/Feb/09  Updated: 08/Aug/09

Status: Closed
Project: pcc
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Major
Reporter: Henry Gebhardt Assignee: Anders Magnusson
Resolution: Fixed Votes: 0
Environment: gcc-4.3.3 on linux x86

File Attachments: Text File pcc-warn_unused_result.patch    

Hi, I recently upgraded gcc from 4.3.2 to 4.3.3, and now pcc no longer compiles due to 'warn_unused_result' treated as errors. The attached patch fixes it, although I am not sure if that is the right approach.

Also, there is another 'warn_unused_result' not treated as error at the very end here (not fixed by patch):
$ make
cd cc && make all
make[1]: Entering directory `/home/hsgg/pcc.git-cvs/cc'
cd cc; make all -w
make[2]: Entering directory `/home/hsgg/pcc.git-cvs/cc/cc'
gcc -DLIBEXECDIR=\"/usr/local/libexec/\" -DINCLUDEDIR=\"/usr/local/include/\" -DPCCINCDIR=\"/usr/local/lib/pcc/i686-pc-linux-gnu/0.9.9/include/\" -DPCCLIBDIR=\"/usr/local/lib/pcc/i686-pc-linux-gnu/0.9.9/lib/\" -Dos_linux -DTARGMACH=i386 -Dmach_i386 -I../.. -I../../os/linux -I../../mip -I../../arch/i386 -g -O2 -Wall -Wmissing-prototypes -Wstrict-prototypes -Wshadow -Wsign-compare -Werror -c cc.c
gcc -DLIBEXECDIR=\"/usr/local/libexec/\" -DINCLUDEDIR=\"/usr/local/include/\" -DPCCINCDIR=\"/usr/local/lib/pcc/i686-pc-linux-gnu/0.9.9/include/\" -DPCCLIBDIR=\"/usr/local/lib/pcc/i686-pc-linux-gnu/0.9.9/lib/\" -Dos_linux -DTARGMACH=i386 -Dmach_i386 -I../.. -I../../os/linux -I../../mip -I../../arch/i386 -g -O2 -Wall -Wmissing-prototypes -Wstrict-prototypes -Wshadow -Wsign-compare -Werror -c -o compat.o ../../mip/compat.c
gcc -g -O2 -Wall -Wmissing-prototypes -Wstrict-prototypes -Wshadow -Wsign-compare -Werror cc.o compat.o -o pcc
make[2]: Leaving directory `/home/hsgg/pcc.git-cvs/cc/cc'
cd cpp; make all -w
make[2]: Entering directory `/home/hsgg/pcc.git-cvs/cc/cpp'
bison -y -d cpy.y
gcc -DCPP_DEBUG -I. -I../.. -I. -I../../mip -I../../arch/i386 -g -O2 -Wall -Wmissing-prototypes -Wstrict-prototypes -Wshadow -Wsign-compare -Werror -c -o cpy.o y.tab.c
gcc -DCPP_DEBUG -I. -I../.. -I. -I../../mip -I../../arch/i386 -g -O2 -Wall -Wmissing-prototypes -Wstrict-prototypes -Wshadow -Wsign-compare -Werror -c cpp.c
flex scanner.l
gcc -DCPP_DEBUG -I. -I../.. -I. -I../../mip -I../../arch/i386 -g -O2 -Wall -Wmissing-prototypes -Wstrict-prototypes -Wshadow -Wsign-compare -Werror -c -o scanner.o lex.yy.c
gcc -DCPP_DEBUG -I. -I../.. -I. -I../../mip -I../../arch/i386 -g -O2 -Wall -Wmissing-prototypes -Wstrict-prototypes -Wshadow -Wsign-compare -Werror -c -o compat.o ../../mip/compat.c
gcc -g -O2 -Wall -Wmissing-prototypes -Wstrict-prototypes -Wshadow -Wsign-compare -Werror cpp.o cpy.o scanner.o compat.o -o cpp
make[2]: Leaving directory `/home/hsgg/pcc.git-cvs/cc/cpp'
cd ccom; make all -w
make[2]: Entering directory `/home/hsgg/pcc.git-cvs/cc/ccom'
gcc -DGCC_COMPAT -DPCC_DEBUG -Dos_linux -Dmach_i386 -D_ISOC99_SOURCE -I. -I. -I../.. -I../../mip -I../../arch/i386 -I../../os/linux -g -O2 -Wall -Wmissing-prototypes -Wstrict-prototypes -Wshadow -Wsign-compare -Werror -DMKEXT -o mkext \
../../mip/mkext.c ../../arch/i386/table.c ../../mip/common.c
rm -f mkext.o table.o common.o
gcc -DGCC_COMPAT -DPCC_DEBUG -Dos_linux -Dmach_i386 -D_ISOC99_SOURCE -I. -I. -I../.. -I../../mip -I../../arch/i386 -I../../os/linux -g -O2 -Wall -Wmissing-prototypes -Wstrict-prototypes -Wshadow -Wsign-compare -Werror -c -o optim.o optim.c
bison -y -d cgram.y
conflicts: 2 shift/reduce
mv y.tab.c cgram.c
mv y.tab.h cgram.h
gcc -DGCC_COMPAT -DPCC_DEBUG -Dos_linux -Dmach_i386 -D_ISOC99_SOURCE -I. -I. -I../.. -I../../mip -I../../arch/i386 -I../../os/linux -g -O2 -Wall -Wmissing-prototypes -Wstrict-prototypes -Wshadow -Wsign-compare -Werror -c -o pftn.o pftn.c
flex scan.l
mv lex.yy.c scan.c
gcc -DGCC_COMPAT -DPCC_DEBUG -Dos_linux -Dmach_i386 -D_ISOC99_SOURCE -I. -I. -I../.. -I../../mip -I../../arch/i386 -I../../os/linux -g -O2 -c -o scan.o scan.c
lex.yy.c: In function 'yylex':
scan.l:219: warning: ignoring return value of 'fwrite', declared with attribute warn_unused_result trees.c
(...continues compiling...)


Comment by Anders Magnusson [ 22/Feb/09 04:39 PM ]
Your fixes are the only way to fix it AFAIK, I'll apply them later.
The warning from scan.l is in code generated by flex, which means that flex on your machine generate code that gcc may fail to compile.
Comment by Henry Gebhardt [ 22/Feb/09 07:18 PM ]
Indeed, the last one is a flex bug, reported in June 2008, link is here for reference:

Since scan.c isn't compiled with -Werror, pcc actually compiles quite well without fixing flex, no action required for now.

Comment by Anders Magnusson [ 08/Aug/09 10:30 AM ]
-Werror is now removed.
Generated at Tue Oct 17 17:01:35 CEST 2017 using JIRA Enterprise Edition, Version: 3.13.1-#333.