public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/111525] New: Inconsistent Wsign-compare in c++ with ubsan
@ 2023-09-21 17:53 zhroma at gcc dot gnu.org
2023-09-21 17:59 ` [Bug c++/111525] " mpolacek at gcc dot gnu.org
2023-09-21 18:00 ` pinskia at gcc dot gnu.org
0 siblings, 2 replies; 3+ messages in thread
From: zhroma at gcc dot gnu.org @ 2023-09-21 17:53 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111525
Bug ID: 111525
Summary: Inconsistent Wsign-compare in c++ with ubsan
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: zhroma at gcc dot gnu.org
Target Milestone: ---
$ cat test.cc
extern long global;
int foo (unsigned x) {
return x == ((global ? 64 : 32) - 1) / 8;
}
$ gcc -x c -c -Werror=sign-compare test.cc
$ gcc -x c -c -Werror=sign-compare test.cc -fsanitize=undefined
$ gcc -x c++ -c -Werror=sign-compare test.cc
$ gcc -x c++ -c -Werror=sign-compare test.cc -fsanitize=undefined
test.cc: In function ‘int foo(unsigned int)’:
test.cc:4:12: error: comparison of integer expressions of different signedness:
‘unsigned int’ and ‘int’ [-Werror=sign-compare]
4 | return x == ((global ? 64 : 32) - 1) / 8;
| ~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cc1plus: some warnings being treated as errors
Warning appears only for C++ with ubsan enabled. It seems that both sanitizer
and warning are implemented in front-end part, and C++ somehow issues warning
after instrumentation.
This actually breaks ubsan-bootstrap with -Werror enabled, from what I know all
versions since gcc-8 are affected.
configure --enable-languages=c,c++ --disable-multilib
--with-build-config=bootstrap-ubsan --enable-werror=yes && make
BOOT_CFLAGS="-Wno-error=array-bounds -Wno-error=format-overflow"
-Wno-error=array-bounds and -Wno-error=format-overflow are necessary as these
warnings have known issues under ubsan.
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug c++/111525] Inconsistent Wsign-compare in c++ with ubsan
2023-09-21 17:53 [Bug c++/111525] New: Inconsistent Wsign-compare in c++ with ubsan zhroma at gcc dot gnu.org
@ 2023-09-21 17:59 ` mpolacek at gcc dot gnu.org
2023-09-21 18:00 ` pinskia at gcc dot gnu.org
1 sibling, 0 replies; 3+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2023-09-21 17:59 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111525
Marek Polacek <mpolacek at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Ever confirmed|0 |1
CC| |mpolacek at gcc dot gnu.org
Last reconfirmed| |2023-09-21
--- Comment #1 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Confirmed.
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug c++/111525] Inconsistent Wsign-compare in c++ with ubsan
2023-09-21 17:53 [Bug c++/111525] New: Inconsistent Wsign-compare in c++ with ubsan zhroma at gcc dot gnu.org
2023-09-21 17:59 ` [Bug c++/111525] " mpolacek at gcc dot gnu.org
@ 2023-09-21 18:00 ` pinskia at gcc dot gnu.org
1 sibling, 0 replies; 3+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-09-21 18:00 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111525
--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
>-Wno-error=array-bounds and -Wno-error=format-overflow are necessary as these warnings have known issues under ubsan.
Actually all warnings have issues with sanitizers enabled. The manual is clear
there too:
https://gcc.gnu.org/onlinedocs/gcc-13.2.0/gcc/Instrumentation-Options.html#index-fsanitize_003daddress
```
Note that sanitizers tend to increase the rate of false positive warnings, most
notably those around -Wmaybe-uninitialized. We recommend against combining
-Werror and [the use of] sanitizers.
```
So I think --disable-werror should be used for configure option instead ...
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-09-21 18:00 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-09-21 17:53 [Bug c++/111525] New: Inconsistent Wsign-compare in c++ with ubsan zhroma at gcc dot gnu.org
2023-09-21 17:59 ` [Bug c++/111525] " mpolacek at gcc dot gnu.org
2023-09-21 18:00 ` pinskia at gcc dot gnu.org
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).