http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56824
Bug #: 56824
Summary: pragma GCC diagnostic push/pop regression for GCC
diagnostic ignored "-Waggregate-return"
Classification: Unclassified
Product: gcc
Version: 4.8.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
AssignedTo: [email protected]
ReportedBy: [email protected]
Created attachment 29784
--> http://gcc.gnu.org/bugzilla/attachment.cgi?id=29784
Simple testcase
If the aggregate-return warning is silenced using
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Waggregate-return"
and then, after a line that triggers the warning, the diagnostics are restored
using
#pragma GCC diagnostic pop
, gcc 4.8 issues an aggregate-return warning. This was not the case in versions
4.6 or 4.7.
With the attached test case, the following is printed:
$ /opt/gcc-4.7/bin/gcc --version
gcc (GCC) 4.7.0
Copyright (C) 2012 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
$ /opt/gcc-4.7/bin/gcc -Waggregate-return -c aggregate-return.c
$ /opt/gcc-4.8/bin/gcc --version
gcc (GCC) 4.8.0
Copyright (C) 2013 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
$ /opt/gcc-4.8/bin/gcc -Waggregate-return -c aggregate-return.c
aggregate-return.c: In function ‘main’:
aggregate-return.c:8:13: warning: function call has aggregate value
[-Waggregate-return]
struct foo f = aggregate_return();
^
$
No warning is printed by either version if the "GCC diagnostic pop" is left
out.
This regression does not affect (at least some) other warnings, e.g. the
following test case:
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-variable"
int main(int argc, char* argv[])
{
int i;
return 0;
}
#pragma GCC diagnostic pop
does not print a warning when compiled with "/opt/gcc-4.8/bin/gcc
-Wunused-variable -c unused.c".