public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "mpolacek at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/96223] New: DR 1787 and indeterminate values in constexpr context Date: Thu, 16 Jul 2020 19:30:59 +0000 [thread overview] Message-ID: <bug-96223-4@http.gcc.gnu.org/bugzilla/> (raw) https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96223 Bug ID: 96223 Summary: DR 1787 and indeterminate values in constexpr context Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: mpolacek at gcc dot gnu.org Target Milestone: --- Use -std=c++20: // DR 1787 #include <cstddef> constexpr int fn1 () { unsigned char foo; unsigned char u = foo; // OK: u has an indeterminate value return u; // UB: copy-init -> standard conversion to int } constexpr int fn2 () { unsigned char foo; int i = foo; // UB return 0; } constexpr int fn3 () { unsigned char foo; char8_t u = foo; // UB: char8_t not an unsigned ordinary character type return 0; } constexpr int fn4 () { std::byte foo; std::byte b = foo; // OK return 0; } constexpr int w1 = fn1 (); constexpr int w2 = fn2 (); constexpr int w3 = fn3 (); constexpr int w4 = fn4 (); DR 1787 says that if an indeterminate value is produced by an evaluation, the behavior is undefined except in certain cases. In fn1 and fn4 we issue errors even for some of the "certain cases" (the lines marked with OK) and I think it's a bug. Uninitialized variables in a constexpr context are OK since C++20 P1331R2.
next reply other threads:[~2020-07-16 19:30 UTC|newest] Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top 2020-07-16 19:30 mpolacek at gcc dot gnu.org [this message] 2020-07-16 19:32 ` [Bug c++/96223] " mpolacek at gcc dot gnu.org 2020-08-06 17:54 ` richard-gccbugzilla at metafoo dot co.uk 2020-08-06 18:00 ` mpolacek at gcc dot gnu.org 2020-09-17 20:15 ` cvs-commit at gcc dot gnu.org 2020-09-17 20:19 ` mpolacek 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-96223-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: linkBe 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).