public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "carlosgalvezp at gmail dot com" <gcc-bugzilla@gcc.gnu.org>
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	[thread overview]
Message-ID: <bug-111714-4@http.gcc.gnu.org/bugzilla/> (raw)

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

            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=56067&action=edit
Test case

Hi!

We are bumping from GCC 7.5 to 9.4 and one of our tests fail. The test works 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 code.
Otherwise it could well be a compiler bug. Is there anything obvious you can
see that could explain the behavior?

Thanks!

             reply	other threads:[~2023-10-06 13:59 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-06 13:59 carlosgalvezp at gmail dot com [this message]
2023-10-06 15:02 ` [Bug c++/111714] " rguenth at gcc dot gnu.org
2023-10-06 15:19 ` pinskia at gcc dot gnu.org
2023-10-06 16:25 ` [Bug tree-optimization/111714] " carlosgalvezp at gmail dot com
2023-10-06 16:26 ` pinskia at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-111714-4@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).