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.
47 lines
1011 B
C
47 lines
1011 B
C
// PR c++/96223
|
|
// { dg-do compile { target c++20 } }
|
|
// DR 1787 (if an indeterminate value is produced by an evaluation, the
|
|
// behavior is undefined except in certain cases)
|
|
// Note that P1331R2 explicitly disallows in a constant evaluation:
|
|
// - an lvalue-to-rvalue conversion that is applied to an object with
|
|
// indeterminate value ([basic.indet]).
|
|
|
|
#include <cstddef>
|
|
|
|
constexpr int
|
|
fn1 ()
|
|
{
|
|
unsigned char foo;
|
|
unsigned char u = foo; // { dg-error "not usable in a constant expression" }
|
|
return 0;
|
|
}
|
|
|
|
constexpr int
|
|
fn2 ()
|
|
{
|
|
unsigned char foo;
|
|
int i = foo; // { dg-error "not usable in a constant expression" }
|
|
return 0;
|
|
}
|
|
|
|
constexpr int
|
|
fn3 ()
|
|
{
|
|
unsigned char foo;
|
|
char8_t u = foo; // { dg-error "not usable in a constant expression" }
|
|
return 0;
|
|
}
|
|
|
|
constexpr int
|
|
fn4 ()
|
|
{
|
|
std::byte foo;
|
|
std::byte b = foo; // { dg-error "not usable in a constant expression" }
|
|
return 0;
|
|
}
|
|
|
|
constexpr int w1 = fn1 ();
|
|
constexpr int w2 = fn2 ();
|
|
constexpr int w3 = fn3 ();
|
|
constexpr int w4 = fn4 ();
|