public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/100976] New: [C++23] Make constexpr reference temp constexpr
@ 2021-06-08 17:46 jason at gcc dot gnu.org
  2021-06-08 17:46 ` [Bug c++/100976] " mpolacek at gcc dot gnu.org
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: jason at gcc dot gnu.org @ 2021-06-08 17:46 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 100976
           Summary: [C++23] Make constexpr reference temp constexpr
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: jason at gcc dot gnu.org
            Blocks: 98940
  Target Milestone: ---

https://wg21.link/cwg2481


Referenced Bugs:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98940
[Bug 98940] Implement C++23 language features

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug c++/100976] [C++23] Make constexpr reference temp constexpr
  2021-06-08 17:46 [Bug c++/100976] New: [C++23] Make constexpr reference temp constexpr jason at gcc dot gnu.org
@ 2021-06-08 17:46 ` mpolacek at gcc dot gnu.org
  2021-06-08 18:45 ` jason at gcc dot gnu.org
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2021-06-08 17:46 UTC (permalink / raw)
  To: gcc-bugs

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

Marek Polacek <mpolacek at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever confirmed|0                           |1
   Last reconfirmed|                            |2021-06-08
                 CC|                            |mpolacek at gcc dot gnu.org

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug c++/100976] [C++23] Make constexpr reference temp constexpr
  2021-06-08 17:46 [Bug c++/100976] New: [C++23] Make constexpr reference temp constexpr jason at gcc dot gnu.org
  2021-06-08 17:46 ` [Bug c++/100976] " mpolacek at gcc dot gnu.org
@ 2021-06-08 18:45 ` jason at gcc dot gnu.org
  2021-06-08 20:51 ` jason at gcc dot gnu.org
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: jason at gcc dot gnu.org @ 2021-06-08 18:45 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Jason Merrill <jason at gcc dot gnu.org> ---
  constexpr const int &r = 42;
  static_assert(r == 42);

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug c++/100976] [C++23] Make constexpr reference temp constexpr
  2021-06-08 17:46 [Bug c++/100976] New: [C++23] Make constexpr reference temp constexpr jason at gcc dot gnu.org
  2021-06-08 17:46 ` [Bug c++/100976] " mpolacek at gcc dot gnu.org
  2021-06-08 18:45 ` jason at gcc dot gnu.org
@ 2021-06-08 20:51 ` jason at gcc dot gnu.org
  2021-07-01 16:55 ` mpolacek at gcc dot gnu.org
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: jason at gcc dot gnu.org @ 2021-06-08 20:51 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Jason Merrill <jason at gcc dot gnu.org> ---
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.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug c++/100976] [C++23] Make constexpr reference temp constexpr
  2021-06-08 17:46 [Bug c++/100976] New: [C++23] Make constexpr reference temp constexpr jason at gcc dot gnu.org
                   ` (2 preceding siblings ...)
  2021-06-08 20:51 ` jason at gcc dot gnu.org
@ 2021-07-01 16:55 ` mpolacek at gcc dot gnu.org
  2021-07-01 20:09 ` mpolacek at gcc dot gnu.org
  2021-07-19 13:59 ` mpolacek at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2021-07-01 16:55 UTC (permalink / raw)
  To: gcc-bugs

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

Marek Polacek <mpolacek at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Assignee|unassigned at gcc dot gnu.org      |mpolacek at gcc dot gnu.org
             Status|NEW                         |ASSIGNED

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug c++/100976] [C++23] Make constexpr reference temp constexpr
  2021-06-08 17:46 [Bug c++/100976] New: [C++23] Make constexpr reference temp constexpr jason at gcc dot gnu.org
                   ` (3 preceding siblings ...)
  2021-07-01 16:55 ` mpolacek at gcc dot gnu.org
@ 2021-07-01 20:09 ` mpolacek at gcc dot gnu.org
  2021-07-19 13:59 ` mpolacek at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2021-07-01 20:09 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
(In reply to Jason Merrill from comment #2)
> 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.

This was actually CWG 2126 which we don't seem to fully implement:

struct A { int n; };

const A &a = {1};              // const temporary
A &b = (A &)(const A &)A{1};   // const temporary
A &&c = (A &&)(const A &)A{1}; // const temporary

static_assert(a.n == 1, "");
static_assert(b.n == 1, "");
static_assert(c.n == 1, "");

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug c++/100976] [C++23] Make constexpr reference temp constexpr
  2021-06-08 17:46 [Bug c++/100976] New: [C++23] Make constexpr reference temp constexpr jason at gcc dot gnu.org
                   ` (4 preceding siblings ...)
  2021-07-01 20:09 ` mpolacek at gcc dot gnu.org
@ 2021-07-19 13:59 ` mpolacek at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2021-07-19 13:59 UTC (permalink / raw)
  To: gcc-bugs

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

Marek Polacek <mpolacek at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |WORKSFORME
             Status|ASSIGNED                    |RESOLVED

--- Comment #4 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Turned out we already implement CWG 2481.  If anyone has a test for something
we don't handle, please open a PR.

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2021-07-19 13:59 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-08 17:46 [Bug c++/100976] New: [C++23] Make constexpr reference temp constexpr jason at gcc dot gnu.org
2021-06-08 17:46 ` [Bug c++/100976] " mpolacek at gcc dot gnu.org
2021-06-08 18:45 ` jason at gcc dot gnu.org
2021-06-08 20:51 ` jason at gcc dot gnu.org
2021-07-01 16:55 ` mpolacek at gcc dot gnu.org
2021-07-01 20:09 ` mpolacek at gcc dot gnu.org
2021-07-19 13:59 ` 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).