public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/99493] New: Address of template parameter object is not a valid template argument
@ 2021-03-09 18:20 johelegp at gmail dot com
  2021-03-15  5:02 ` [Bug c++/99493] " johelegp at gmail dot com
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: johelegp at gmail dot com @ 2021-03-09 18:20 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 99493
           Summary: Address of template parameter object is not a valid
                    template argument
           Product: gcc
           Version: 11.0
               URL: https://godbolt.org/z/9zYo8f
            Status: UNCONFIRMED
          Keywords: rejects-valid
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: johelegp at gmail dot com
                CC: johelegp at gmail dot com
  Target Milestone: ---

See https://godbolt.org/z/9zYo8f.
```C++
struct owner{int m;};
struct view{const int*m;constexpr view(const owner&o):m{&o.m}{}};
template<view V>struct constant{};
template<owner O>constexpr constant<O>v{};
[[maybe_unused]] constexpr auto a=v<owner{}>;
```
https://timsong-cpp.github.io/cppwp/n4861/temp.param#8 defines template
parameter object.
https://timsong-cpp.github.io/cppwp/n4861/temp.arg.nontype#2 makes the template
parameter object a constant expression.
https://timsong-cpp.github.io/cppwp/n4861/temp.arg.nontype#3 lists
restrictions, which excludes taking the address of a template parameter object.

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

* [Bug c++/99493] Address of template parameter object is not a valid template argument
  2021-03-09 18:20 [Bug c++/99493] New: Address of template parameter object is not a valid template argument johelegp at gmail dot com
@ 2021-03-15  5:02 ` johelegp at gmail dot com
  2021-03-15 18:44 ` johelegp at gmail dot com
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: johelegp at gmail dot com @ 2021-03-15  5:02 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Johel Ernesto Guerrero Peña <johelegp at gmail dot com> ---
Slightly simplified: https://godbolt.org/z/rv97Gh.
```C++
struct A{};
template<A a>constexpr const A*tpo{&a};
template<const A*>struct B{};
B<tpo<A{}>>b;
```
```
<source>:4:10: error: the address of 'A{}' is not a valid template argument
    4 | B<tpo<A{}>>b;
      |          ^~
Compiler returned: 1
```

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

* [Bug c++/99493] Address of template parameter object is not a valid template argument
  2021-03-09 18:20 [Bug c++/99493] New: Address of template parameter object is not a valid template argument johelegp at gmail dot com
  2021-03-15  5:02 ` [Bug c++/99493] " johelegp at gmail dot com
@ 2021-03-15 18:44 ` johelegp at gmail dot com
  2022-01-19  2:43 ` pinskia at gcc dot gnu.org
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: johelegp at gmail dot com @ 2021-03-15 18:44 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Johel Ernesto Guerrero Peña <johelegp at gmail dot com> ---
Looks like you can get away by instead passing around a pointer to the address
of the template parameter object: https://godbolt.org/z/o3Paz1.
```C++
struct A{};
template<A a>constexpr const A*tpo{&a};
constexpr A ga{};
template<const A*const*a>requires(a==&tpo<ga>)struct B{};
[[maybe_unused]]B<&tpo<A{}>>b;
```

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

* [Bug c++/99493] Address of template parameter object is not a valid template argument
  2021-03-09 18:20 [Bug c++/99493] New: Address of template parameter object is not a valid template argument johelegp at gmail dot com
  2021-03-15  5:02 ` [Bug c++/99493] " johelegp at gmail dot com
  2021-03-15 18:44 ` johelegp at gmail dot com
@ 2022-01-19  2:43 ` pinskia at gcc dot gnu.org
  2022-01-19  2:46 ` pinskia at gcc dot gnu.org
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-01-19  2:43 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                URL|https://godbolt.org/z/9zYo8 |
                   |f                           |

--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
https://godbolt.org/z/9zYo8f

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

* [Bug c++/99493] Address of template parameter object is not a valid template argument
  2021-03-09 18:20 [Bug c++/99493] New: Address of template parameter object is not a valid template argument johelegp at gmail dot com
                   ` (2 preceding siblings ...)
  2022-01-19  2:43 ` pinskia at gcc dot gnu.org
@ 2022-01-19  2:46 ` pinskia at gcc dot gnu.org
  2024-01-17 18:02 ` cvs-commit at gcc dot gnu.org
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-01-19  2:46 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever confirmed|0                           |1
   Last reconfirmed|                            |2022-01-19

--- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Confirmed.

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

* [Bug c++/99493] Address of template parameter object is not a valid template argument
  2021-03-09 18:20 [Bug c++/99493] New: Address of template parameter object is not a valid template argument johelegp at gmail dot com
                   ` (3 preceding siblings ...)
  2022-01-19  2:46 ` pinskia at gcc dot gnu.org
@ 2024-01-17 18:02 ` cvs-commit at gcc dot gnu.org
  2024-01-18 15:53 ` cvs-commit at gcc dot gnu.org
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2024-01-17 18:02 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Patrick Palka <ppalka@gcc.gnu.org>:

https://gcc.gnu.org/g:68cea2d32a9fd525154b6a48042e5835d4c5e371

commit r14-8189-g68cea2d32a9fd525154b6a48042e5835d4c5e371
Author: Patrick Palka <ppalka@redhat.com>
Date:   Wed Jan 17 13:01:01 2024 -0500

    c++: address of class NTTP object as targ [PR113242]

    invalid_tparm_referent_p was rejecting using the address of a class NTTP
    object as a template argument, but this should be fine.

            PR c++/113242
            PR c++/99493

    gcc/cp/ChangeLog:

            * pt.cc (invalid_tparm_referent_p) <case ADDR_EXPR>: Suppress
            DECL_ARTIFICIAL rejection test for class NTTP objects.

    gcc/testsuite/ChangeLog:

            * g++.dg/cpp2a/nontype-class61.C: New test.
            * g++.dg/cpp2a/nontype-class62.C: New test.

    Reviewed-by: Jason Merrill <jason@redhat.com>

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

* [Bug c++/99493] Address of template parameter object is not a valid template argument
  2021-03-09 18:20 [Bug c++/99493] New: Address of template parameter object is not a valid template argument johelegp at gmail dot com
                   ` (4 preceding siblings ...)
  2024-01-17 18:02 ` cvs-commit at gcc dot gnu.org
@ 2024-01-18 15:53 ` cvs-commit at gcc dot gnu.org
  2024-01-18 15:54 ` ppalka at gcc dot gnu.org
  2024-01-18 15:55 ` johelegp at gmail dot com
  7 siblings, 0 replies; 9+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2024-01-18 15:53 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #6 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-13 branch has been updated by Patrick Palka
<ppalka@gcc.gnu.org>:

https://gcc.gnu.org/g:4ffb23975b32bfd285915c3d6659b837868b5aa9

commit r13-8235-g4ffb23975b32bfd285915c3d6659b837868b5aa9
Author: Patrick Palka <ppalka@redhat.com>
Date:   Wed Jan 17 13:01:01 2024 -0500

    c++: address of class NTTP object as targ [PR113242]

    invalid_tparm_referent_p was rejecting using the address of a class NTTP
    object as a template argument, but this should be fine.

            PR c++/113242
            PR c++/99493

    gcc/cp/ChangeLog:

            * pt.cc (invalid_tparm_referent_p) <case ADDR_EXPR>: Suppress
            DECL_ARTIFICIAL rejection test for class NTTP objects.

    gcc/testsuite/ChangeLog:

            * g++.dg/cpp2a/nontype-class61.C: New test.
            * g++.dg/cpp2a/nontype-class62.C: New test.

    Reviewed-by: Jason Merrill <jason@redhat.com>
    (cherry picked from commit 68cea2d32a9fd525154b6a48042e5835d4c5e371)

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

* [Bug c++/99493] Address of template parameter object is not a valid template argument
  2021-03-09 18:20 [Bug c++/99493] New: Address of template parameter object is not a valid template argument johelegp at gmail dot com
                   ` (5 preceding siblings ...)
  2024-01-18 15:53 ` cvs-commit at gcc dot gnu.org
@ 2024-01-18 15:54 ` ppalka at gcc dot gnu.org
  2024-01-18 15:55 ` johelegp at gmail dot com
  7 siblings, 0 replies; 9+ messages in thread
From: ppalka at gcc dot gnu.org @ 2024-01-18 15:54 UTC (permalink / raw)
  To: gcc-bugs

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

Patrick Palka <ppalka at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
   Target Milestone|---                         |13.3
         Resolution|---                         |FIXED
                 CC|                            |ppalka at gcc dot gnu.org
           Assignee|unassigned at gcc dot gnu.org      |ppalka at gcc dot gnu.org

--- Comment #7 from Patrick Palka <ppalka at gcc dot gnu.org> ---
Fixed for GCC 13.3 / 14.

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

* [Bug c++/99493] Address of template parameter object is not a valid template argument
  2021-03-09 18:20 [Bug c++/99493] New: Address of template parameter object is not a valid template argument johelegp at gmail dot com
                   ` (6 preceding siblings ...)
  2024-01-18 15:54 ` ppalka at gcc dot gnu.org
@ 2024-01-18 15:55 ` johelegp at gmail dot com
  7 siblings, 0 replies; 9+ messages in thread
From: johelegp at gmail dot com @ 2024-01-18 15:55 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #8 from Johel Ernesto Guerrero Peña <johelegp at gmail dot com> ---
Thank you!

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

end of thread, other threads:[~2024-01-18 15:55 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-09 18:20 [Bug c++/99493] New: Address of template parameter object is not a valid template argument johelegp at gmail dot com
2021-03-15  5:02 ` [Bug c++/99493] " johelegp at gmail dot com
2021-03-15 18:44 ` johelegp at gmail dot com
2022-01-19  2:43 ` pinskia at gcc dot gnu.org
2022-01-19  2:46 ` pinskia at gcc dot gnu.org
2024-01-17 18:02 ` cvs-commit at gcc dot gnu.org
2024-01-18 15:53 ` cvs-commit at gcc dot gnu.org
2024-01-18 15:54 ` ppalka at gcc dot gnu.org
2024-01-18 15:55 ` johelegp at gmail dot com

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).