From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id B2484385828E; Fri, 6 Oct 2023 13:59:15 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B2484385828E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1696600755; bh=80ivkB0so2yVaTCCWAFiEZm4gYysEoGGaqWvpOET+EQ=; h=From:To:Subject:Date:From; b=RpoUtZWc2S0j43sXkHY/xHhheOOlqgzhbtNw8kmYDcz5e0PLb4tTkpCeLhLPIcyAL rXPc1DtP0e3WcVCXV1Dx8OBSPgivHhLPGc+7J9bcFHp47LphAPD96d8QgnFJHGUywb WT9OB9bhh0CT62eEx2C5KP5wMZOq2t5MmZgRbPDk= From: "carlosgalvezp at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/111714] New: Strange behavior when casting std::size_t to bool, UB or compiler bug? Date: Fri, 06 Oct 2023 13:59:15 +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: 9.4.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: carlosgalvezp at gmail dot com 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: 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=3D111714 Bug ID: 111714 Summary: Strange behavior when casting std::size_t to bool, UB or compiler bug? Product: gcc Version: 9.4.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: carlosgalvezp at gmail dot com Target Milestone: --- Created attachment 56067 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=3D56067&action=3Dedit Test case Hi! We are bumping from GCC 7.5 to 9.4 and one of our tests fail. The test work= s on GCC 10 and above, as well as Clang trunk. Sanitizers (GCC and Clang) and Valgrind don't report anything. I have managed to create a minimal example here: https://godbolt.org/z/3q7c4qYzE (attached to the bug as a file as well). There's also comments about changes to the code that can make the test pass. This smells a lot like UB, but I can't figure out what is wrong with the co= de. Otherwise it could well be a compiler bug. Is there anything obvious you can see that could explain the behavior? Thanks!=