I really don't know, why it doesn't work. The only idea I have is that it somehow conflicts with the attribute "warn_unused_result" given to the read/write/... functions in the glibc headers.
This is my output when compiling without the patch:
g++ -DHAVE_CONFIG_H -I. -I.. -I../include -I../utils -I../utils -I../marshal -I../ssl -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -fno-strict-aliasing -pthread -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -Wall -Wpointer-arith -Wformat=2 -Wformat-security -Wformat-nonliteral -Wcast-qual -Wcast-align -Wshadow -Wwrite-strings -Wredundant-decls -Wno-strict-aliasing -Wno-unused-value -Werror -D_GNU_SOURCE -D_REENTRANT -fexceptions -MT openhpid.o -MD -MP -MF .deps/openhpid.Tpo -c -o openhpid.o openhpid.cpp
cc1plus: warnings being treated as errors
openhpid.cpp: In function 'int main(int, char**)':
openhpid.cpp:229: error: ignoring return value of 'ssize_t write(int, const void*, size_t)', declared with attribute warn_unused_result
openhpid.cpp: In function 'bool morph2daemon()':
openhpid.cpp:358: error: ignoring return value of 'ssize_t write(int, const void*, size_t)', declared with attribute warn_unused_result
I will try to create a minimal example that reveals this behaviour.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
>dhorak< jakub: ping, is it correct that when the result of a function with attribute warn_unused_result is not used, then adding -Wno-unused-value has no effect on the warning that gcc emits?
-jakub- dhorak: yes, -Wunused-value is unrelated and warn_unused_result attribute warnings are unconditional
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
remove warnings on ignored return values
Logged In: YES
user_id=660960
Originator: NO
I don't get how can this happen when -Wno-unused-value is being specified after -Wall. Do you know why?
Logged In: YES
user_id=8942
Originator: YES
I really don't know, why it doesn't work. The only idea I have is that it somehow conflicts with the attribute "warn_unused_result" given to the read/write/... functions in the glibc headers.
This is my output when compiling without the patch:
g++ -DHAVE_CONFIG_H -I. -I.. -I../include -I../utils -I../utils -I../marshal -I../ssl -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -fno-strict-aliasing -pthread -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -Wall -Wpointer-arith -Wformat=2 -Wformat-security -Wformat-nonliteral -Wcast-qual -Wcast-align -Wshadow -Wwrite-strings -Wredundant-decls -Wno-strict-aliasing -Wno-unused-value -Werror -D_GNU_SOURCE -D_REENTRANT -fexceptions -MT openhpid.o -MD -MP -MF .deps/openhpid.Tpo -c -o openhpid.o openhpid.cpp
cc1plus: warnings being treated as errors
openhpid.cpp: In function 'int main(int, char**)':
openhpid.cpp:229: error: ignoring return value of 'ssize_t write(int, const void*, size_t)', declared with attribute warn_unused_result
openhpid.cpp: In function 'bool morph2daemon()':
openhpid.cpp:358: error: ignoring return value of 'ssize_t write(int, const void*, size_t)', declared with attribute warn_unused_result
I will try to create a minimal example that reveals this behaviour.
Logged In: YES
user_id=8942
Originator: YES
Believe or not it is affected by the "-O2". Try the attached test script.
File Added: g
Logged In: YES
user_id=8942
Originator: YES
Another test case created - when a function is defined with attribute warn_unused_result then using -Wno-unused-value has no effect.
File Added: g1
Logged In: YES
user_id=8942
Originator: YES
Including answer from our GCC guru:
>dhorak< jakub: ping, is it correct that when the result of a function with attribute warn_unused_result is not used, then adding -Wno-unused-value has no effect on the warning that gcc emits?
-jakub- dhorak: yes, -Wunused-value is unrelated and warn_unused_result attribute warnings are unconditional
Logged In: YES
user_id=901950
Originator: NO
Apply the supplied patch to trunk.