public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/66099] New: _Pragma diagnostic 'ignored' in macro with strict-overflow not suppressing warning fully with -Werror
@ 2015-05-10 22:24 dd0t at users dot sourceforge.net
  2015-05-10 22:27 ` [Bug c++/66099] " dd0t at users dot sourceforge.net
  0 siblings, 1 reply; 2+ messages in thread
From: dd0t at users dot sourceforge.net @ 2015-05-10 22:24 UTC (permalink / raw)
  To: gcc-bugs

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;
}


^ permalink raw reply	[flat|nested] 2+ messages in thread

* [Bug c++/66099] _Pragma diagnostic 'ignored' in macro with strict-overflow not suppressing warning fully with -Werror
  2015-05-10 22:24 [Bug c++/66099] New: _Pragma diagnostic 'ignored' in macro with strict-overflow not suppressing warning fully with -Werror dd0t at users dot sourceforge.net
@ 2015-05-10 22:27 ` dd0t at users dot sourceforge.net
  0 siblings, 0 replies; 2+ messages in thread
From: dd0t at users dot sourceforge.net @ 2015-05-10 22:27 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66099

--- Comment #1 from Stefan H. <dd0t at users dot sourceforge.net> ---
I actually meant to link https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66098 as
a potentially related bug and not 53469. Sorry about that.


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-05-10 22:27 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-05-10 22:24 [Bug c++/66099] New: _Pragma diagnostic 'ignored' in macro with strict-overflow not suppressing warning fully with -Werror dd0t at users dot sourceforge.net
2015-05-10 22:27 ` [Bug c++/66099] " dd0t at users dot sourceforge.net

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).