From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 49693 invoked by alias); 10 May 2015 22:24:15 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Received: (qmail 49675 invoked by uid 48); 10 May 2015 22:24:11 -0000 From: "dd0t at users dot sourceforge.net" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/66099] New: _Pragma diagnostic 'ignored' in macro with strict-overflow not suppressing warning fully with -Werror Date: Sun, 10 May 2015 22:24:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: 5.1.1 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: dd0t at users dot sourceforge.net X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone attachments.created Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2015-05/txt/msg00808.txt.bz2 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66099 Bug ID: 66099 Summary: _Pragma diagnostic 'ignored' in macro with strict-overflow not suppressing warning fully with -Werror Product: gcc Version: 5.1.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: dd0t at users dot sourceforge.net Target Milestone: --- Created attachment 35517 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=35517&action=edit Repro case with description When compiling the attached sample with g++ 5.1.0 or 5.1.1 and -Werror the suppression of strict-overflow works for the approaches taken in the testing2 and testing3 functions but the analogous one in the TESTING macro will still produce a strict-overflow warning. This warning will strangely - even though -Werror is set - not result in an error though. With g++ 4.9.2 the diagnostic ignored seems to have no effect at all and a warning with resulting error is created in the TESTING macro. When compiling with gcc instead of g++ - as intended - none of the approaches leads to a warning or an error in any of the aforementioned versions. A related bug might be https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53469 . I found it when trying to create the repro sample for this bug. https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53431 has the same g++ only behavior but - with my limited understanding of g++ internals - I wouldn't expect the strict-overflow warning to be created in that early processing stage causing that issue. Repro sample: // g++ -fstrict-overflow -Wstrict-overflow -Werror macro.c // gcc -fstrict-overflow -Wstrict-overflow -Werror macro.c // Under g++: // The TESTING macro still presents a strict-overflow warning // with gcc 5.1.0 and 5.1.1 even though it should be ignored. // With gcc 4.9.2 the ignore is completely ignored and the // compilation fails due to the incorrectly generated warning. // Under gcc: // Works as expected in all versions. #define TESTING(_Exp) { \ _Pragma("GCC diagnostic push") \ _Pragma("GCC diagnostic ignored \"-Wstrict-overflow\"") \ int b = _Exp ; \ _Pragma("GCC diagnostic pop") \ } void testing() { int i = 4; TESTING(i + 4 < i); } void testing2() { #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wstrict-overflow" int j = 4; int b = j + 4 < j; #pragma GCC diagnostic pop } void testing3() { _Pragma("GCC diagnostic push") _Pragma("GCC diagnostic ignored \"-Wstrict-overflow\"") int k = 4; int b = k + 4 < k; _Pragma("GCC diagnostic pop") } int main() { testing(); testing2(); testing3(); return 0; }