Bug 100976 - [C++23] Make constexpr reference temp constexpr
Summary: [C++23] Make constexpr reference temp constexpr
Status: NEW
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 12.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks: c++23-core
  Show dependency treegraph
 
Reported: 2021-06-08 17:46 UTC by Jason Merrill
Modified: 2021-06-09 04:53 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2021-06-08 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jason Merrill 2021-06-08 17:46:11 UTC
https://wg21.link/cwg2481
Comment 1 Jason Merrill 2021-06-08 18:45:22 UTC
  constexpr const int &r = 42;
  static_assert(r == 42);
Comment 2 Jason Merrill 2021-06-08 20:51:35 UTC
Or rather,

int main()
{
  constexpr const int &r = 42;
  static_assert(r == 42); // { dg-bogus "" }
}

[expr.const]/4.7 says that "a temporary object of non-volatile const-qualified literal type whose lifetime is extended to that
of a variable that is usable in constant expressions" is usable in a constant expression.