public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
* [Bug c++/96223] New: DR 1787 and indeterminate values in constexpr context @ 2020-07-16 19:30 mpolacek at gcc dot gnu.org 2020-07-16 19:32 ` [Bug c++/96223] " mpolacek at gcc dot gnu.org ` (4 more replies) 0 siblings, 5 replies; 6+ messages in thread From: mpolacek at gcc dot gnu.org @ 2020-07-16 19:30 UTC (permalink / raw) To: gcc-bugs 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. ^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/96223] DR 1787 and indeterminate values in constexpr context 2020-07-16 19:30 [Bug c++/96223] New: DR 1787 and indeterminate values in constexpr context mpolacek at gcc dot gnu.org @ 2020-07-16 19:32 ` mpolacek at gcc dot gnu.org 2020-08-06 17:54 ` richard-gccbugzilla at metafoo dot co.uk ` (3 subsequent siblings) 4 siblings, 0 replies; 6+ messages in thread From: mpolacek at gcc dot gnu.org @ 2020-07-16 19:32 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96223 --- Comment #1 from Marek Polacek <mpolacek at gcc dot gnu.org> --- Note that is_byte_access_type won't do, because it includes char8_t too. ^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/96223] DR 1787 and indeterminate values in constexpr context 2020-07-16 19:30 [Bug c++/96223] New: DR 1787 and indeterminate values in constexpr context mpolacek at gcc dot gnu.org 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 ` (2 subsequent siblings) 4 siblings, 0 replies; 6+ messages in thread From: richard-gccbugzilla at metafoo dot co.uk @ 2020-08-06 17:54 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96223 Richard Smith <richard-gccbugzilla at metafoo dot co.uk> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |richard-gccbugzilla@metafoo | |.co.uk --- Comment #2 from Richard Smith <richard-gccbugzilla at metafoo dot co.uk> --- P1331R2 explicitly disallows in a constant evaluation: "- an lvalue-to-rvalue conversion that is applied to an object with indeterminate value ([basic.indet]);" so GCC is correct to reject such cases. ^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/96223] DR 1787 and indeterminate values in constexpr context 2020-07-16 19:30 [Bug c++/96223] New: DR 1787 and indeterminate values in constexpr context mpolacek at gcc dot gnu.org 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 4 siblings, 0 replies; 6+ messages in thread From: mpolacek at gcc dot gnu.org @ 2020-08-06 18:00 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96223 Marek Polacek <mpolacek at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords|rejects-valid | Assignee|unassigned at gcc dot gnu.org |mpolacek at gcc dot gnu.org Last reconfirmed| |2020-08-06 Status|UNCONFIRMED |ASSIGNED Ever confirmed|0 |1 --- Comment #3 from Marek Polacek <mpolacek at gcc dot gnu.org> --- Aaah, I see. Thanks a lot! I'll add the test at least. ^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/96223] DR 1787 and indeterminate values in constexpr context 2020-07-16 19:30 [Bug c++/96223] New: DR 1787 and indeterminate values in constexpr context mpolacek at gcc dot gnu.org ` (2 preceding siblings ...) 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 4 siblings, 0 replies; 6+ messages in thread From: cvs-commit at gcc dot gnu.org @ 2020-09-17 20:15 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96223 --- Comment #4 from CVS Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by Marek Polacek <mpolacek@gcc.gnu.org>: https://gcc.gnu.org/g:4f0aa5b051c0d3e81478bcb495e4e072b2d9827d commit r11-3268-g4f0aa5b051c0d3e81478bcb495e4e072b2d9827d Author: Marek Polacek <polacek@redhat.com> Date: Thu Sep 17 15:31:50 2020 -0400 c++: Add tests for fixed PRs. Bugzilla inspection turned up a bunch of old(er) PRs that have been fixed. Let's include them not to regress in the future. gcc/testsuite/ChangeLog: PR c++/87530 PR c++/58156 PR c++/68828 PR c++/86002 PR c++/91525 PR c++/96223 PR c++/87032 PR c++/35098 * g++.dg/cpp0x/move-return4.C: New test. * g++.dg/cpp0x/vt-58156.C: New test. * g++.dg/cpp2a/concepts-pr68828.C: New test. * g++.dg/cpp2a/concepts-pr86002.C: New test. * g++.dg/cpp2a/concepts-pr91525.C: New test. * g++.dg/cpp2a/constexpr-indeterminate1.C: New test. * g++.dg/cpp2a/desig17.C: New test. * g++.dg/ext/attrib62.C: New test. ^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/96223] DR 1787 and indeterminate values in constexpr context 2020-07-16 19:30 [Bug c++/96223] New: DR 1787 and indeterminate values in constexpr context mpolacek at gcc dot gnu.org ` (3 preceding siblings ...) 2020-09-17 20:15 ` cvs-commit at gcc dot gnu.org @ 2020-09-17 20:19 ` mpolacek at gcc dot gnu.org 4 siblings, 0 replies; 6+ messages in thread From: mpolacek at gcc dot gnu.org @ 2020-09-17 20:19 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96223 Marek Polacek <mpolacek at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Resolution|--- |FIXED Status|ASSIGNED |RESOLVED --- Comment #5 from Marek Polacek <mpolacek at gcc dot gnu.org> --- Test added. ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2020-09-17 20:19 UTC | newest] Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2020-07-16 19:30 [Bug c++/96223] New: DR 1787 and indeterminate values in constexpr context mpolacek at gcc dot gnu.org 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
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).