From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id C956F3858C52; Thu, 21 Sep 2023 17:53:12 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C956F3858C52 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1695318792; bh=WfFxHqNshMKZN301/RDHVjjSQDs5ek/nevrLg7Yc7fs=; h=From:To:Subject:Date:From; b=Ouq1K3jsjIsofN+yXRP8pgn6Ewm19ut2YWWvlzz8uhHNd6uTVykjuqzDvrgc49euF zrmpvW7/gxqeUo9C6WiVZ2fqc+jCPAJLzJKASqT7VijgQdelrexeSeK7S4fcwBTjAh uRifhQAW7GwQx9vjieT8Wl+Z4GjY2lOhUPFEaCM4= From: "zhroma at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/111525] New: Inconsistent Wsign-compare in c++ with ubsan Date: Thu, 21 Sep 2023 17:53:12 +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: unknown X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: zhroma at gcc dot gnu.org 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 Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D111525 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=20 extern long global; int foo (unsigned x) { return x =3D=3D ((global ? 64 : 32) - 1) / 8; } $ gcc -x c -c -Werror=3Dsign-compare test.cc $ gcc -x c -c -Werror=3Dsign-compare test.cc -fsanitize=3Dundefined $ gcc -x c++ -c -Werror=3Dsign-compare test.cc $ gcc -x c++ -c -Werror=3Dsign-compare test.cc -fsanitize=3Dundefined test.cc: In function =E2=80=98int foo(unsigned int)=E2=80=99: test.cc:4:12: error: comparison of integer expressions of different signedn= ess: =E2=80=98unsigned int=E2=80=99 and =E2=80=98int=E2=80=99 [-Werror=3Dsign-co= mpare] 4 | return x =3D=3D ((global ? 64 : 32) - 1) / 8; | ~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ cc1plus: some warnings being treated as errors Warning appears only for C++ with ubsan enabled. It seems that both saniti= zer and warning are implemented in front-end part, and C++ somehow issues warni= ng after instrumentation. This actually breaks ubsan-bootstrap with -Werror enabled, from what I know= all versions since gcc-8 are affected. configure --enable-languages=3Dc,c++ --disable-multilib --with-build-config=3Dbootstrap-ubsan --enable-werror=3Dyes && make BOOT_CFLAGS=3D"-Wno-error=3Darray-bounds -Wno-error=3Dformat-overflow" -Wno-error=3Darray-bounds and -Wno-error=3Dformat-overflow are necessary as= these warnings have known issues under ubsan.=