Created attachment 45687 [details] minimum test case This is an issue I was having where g++ was outputting over 56,000 spurious warnings for a project I was building. I found that the problem only came from including Eigen/Core header amongst various project headers that declared operators. I was able to use singledelta to minimize the test case down to the attached file. After the #pragma which comes from Eigen, it seems to break g++'s ability to differentiate between different operator signatures and just warns that they are all previously defined with different attributes. Here is the warning output from g++: testcase-min.i:4:37: warning: optimization attribute on 'int& operator<<(int&, const B&)' follows definition but the attribute doesn't match [-Wattributes] int &operator<<(int &i, const B &ast); ^ testcase-min.i:1:35: note: previous definition of 'int& operator<<(int&, const A&)' was here class A { private: friend int &operator<<(int &i, const A &value) { return i; } }; ^~~~~~~~
Confirmed, started with r236129 and is probably hidden on trunk due to r265744.
Doesn't look like hidden to me, I'd say that r265744 has been the right fix for this. The diagnose_mismatched_attributes has been simply placed way too early, before we check if the two decls actually shouldn't be merged because they have different arguments (and not extern "C"). I'd say we should just say this is fixed for 9 and decide how to fix on release branches. Let me prepare a patch with some testcases for trunk.
Testsuite patch https://gcc.gnu.org/ml/gcc-patches/2019-04/msg00494.html
Author: jakub Date: Wed Apr 17 19:24:55 2019 New Revision: 270422 URL: https://gcc.gnu.org/viewcvs?rev=270422&root=gcc&view=rev Log: PR c++/89325 * g++.dg/ext/attrib58.C: New test. * g++.dg/ext/attrib59.C: New test. * g++.dg/ext/attrib60.C: New test. Added: trunk/gcc/testsuite/g++.dg/ext/attrib58.C trunk/gcc/testsuite/g++.dg/ext/attrib59.C trunk/gcc/testsuite/g++.dg/ext/attrib60.C Modified: trunk/gcc/testsuite/ChangeLog
I have the same problem. Minimal test case: #include <math.h> struct Test { float f; }; Test round(Test const & a) __attribute__ ((optimize("-fno-unsafe-math-optimizations"))); Test round(Test const & a) {return a;}
Related: http://eigen.tuxfamily.org/bz/show_bug.cgi?id=1724 We just mask the warning for g++-7 at the moment.
The GCC 7 branch is being closed, re-targeting to GCC 8.4.
GCC 8.4.0 has been released, adjusting target milestone.
The GCC 8 branch is being closed, fixed in GCC 9.1.