https://gcc.gnu.org/bugzilla/show_bug.cgi?id=121009
Bug ID: 121009 Summary: [libgomp]fwrite return value ignored in libgomp/error.c causes build failure with -Werror=unused-result Product: gcc Version: 14.3.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: libgomp Assignee: unassigned at gcc dot gnu.org Reporter: dongjianqiang2 at huawei dot com CC: jakub at gcc dot gnu.org Target Milestone: --- When building GCC/libgomp with -Werror=unused-result, the build fails due to fwrite() return values being ignored in libgomp/error.c. This happens because some versions of glibc declare fwrite() with __attribute__((__warn_unused_result__)). https://github.com/bminor/glibc/blob/glibc-2.8/libio/stdio.h#L685 This makes the build fail with: gcc/libgomp/error.c: In function 'GOMP_warning': gcc/libgomp/error.c:101:7: error: ignoring return value of 'fwrite', declared with attribute warn_unused_result [-Werror=unused-result] fwrite (msg, 1, msglen, stderr); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ gcc/libgomp/error.c: In function 'GOMP_error': gcc/libgomp/error.c:116:7: error: ignoring return value of 'fwrite' declared with attribute 'warn_unused_result' [-Werror=unused-result] fwrite (msg, 1, msglen, stderr); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~