public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/91798] Compiler rejects code due to template specialization of auto parameter value.
       [not found] <bug-91798-4@http.gcc.gnu.org/bugzilla/>
@ 2021-03-08 10:12 ` redi at gcc dot gnu.org
  2021-08-05  6:02 ` pinskia at gcc dot gnu.org
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 5+ messages in thread
From: redi at gcc dot gnu.org @ 2021-03-08 10:12 UTC (permalink / raw)
  To: gcc-bugs

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

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           See Also|                            |https://gcc.gnu.org/bugzill
                   |                            |a/show_bug.cgi?id=86933
   Last reconfirmed|2020-01-29 00:00:00         |2021-3-8

--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Possibly a dup of PR 86933

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

* [Bug c++/91798] Compiler rejects code due to template specialization of auto parameter value.
       [not found] <bug-91798-4@http.gcc.gnu.org/bugzilla/>
  2021-03-08 10:12 ` [Bug c++/91798] Compiler rejects code due to template specialization of auto parameter value redi at gcc dot gnu.org
@ 2021-08-05  6:02 ` pinskia at gcc dot gnu.org
  2024-04-06  2:37 ` pinskia at gcc dot gnu.org
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 5+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-08-05  6:02 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
                URL|https://wandbox.org/permlin |
                   |k/YuXR4WMYflBZTW4m          |
   Last reconfirmed|2021-03-08 00:00:00         |2021-8-4

--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to Jonathan Wakely from comment #2)
> Possibly a dup of PR 86933

I highly doubt it.
This is about 0u vs 0 while that one has to deal with pointer-to-member

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

* [Bug c++/91798] Compiler rejects code due to template specialization of auto parameter value.
       [not found] <bug-91798-4@http.gcc.gnu.org/bugzilla/>
  2021-03-08 10:12 ` [Bug c++/91798] Compiler rejects code due to template specialization of auto parameter value redi at gcc dot gnu.org
  2021-08-05  6:02 ` pinskia at gcc dot gnu.org
@ 2024-04-06  2:37 ` pinskia at gcc dot gnu.org
  2024-04-06  2:45 ` pinskia at gcc dot gnu.org
  2024-04-06  2:46 ` pinskia at gcc dot gnu.org
  4 siblings, 0 replies; 5+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-04-06  2:37 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Actually maybe GCC is correct here.
Remove the variadic template:
```
//Get type parameter at given index.
template<auto i>
struct param
{
    static_assert(i > 0, "Index into parameter pack cannot be negative!");
    using type = typename param<i - 1>::type;
};

template<>
struct param<0>
{
    using type = int;
};

int main()
{
    typename param<0u>::type x = 'a';
    static_cast<void>(x);
}
```

Every compiler (EDG, GCC, clang and MSVC) I tried rejects this.

Note the original code,  EDG rejects it for the same reason as GCC.

The reason why is 0 is different 0u as they have different types as they should
not match.

Though I think there is a defect report in that area ...

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

* [Bug c++/91798] Compiler rejects code due to template specialization of auto parameter value.
       [not found] <bug-91798-4@http.gcc.gnu.org/bugzilla/>
                   ` (2 preceding siblings ...)
  2024-04-06  2:37 ` pinskia at gcc dot gnu.org
@ 2024-04-06  2:45 ` pinskia at gcc dot gnu.org
  2024-04-06  2:46 ` pinskia at gcc dot gnu.org
  4 siblings, 0 replies; 5+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-04-06  2:45 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |SUSPENDED

--- Comment #5 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
https://www.open-std.org/jtc1/sc22/wg21/docs/cwg_active.html#1647

And maybe others.

Note my other testcase was a full specialization rather than a partial.
Here is one with a partial which removes the variadic :
```
//Get type parameter at given index.
template<auto i, class T>
struct param
{
    static_assert(i > 0, "Index into parameter pack cannot be negative!");
    using type = typename param<i - 1, T>::type;
};

template<class T>
struct param<0, T>
{
    using type = T;
};

int main()
{
    typename param<0u, int>::type x = 'a';
    static_cast<void>(x);
}
```

Both GCC and EDG agree on this while clang and MSVC disagree. This is
definitely DR 1647 then. 

So suspended as the defect report is still active.

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

* [Bug c++/91798] Compiler rejects code due to template specialization of auto parameter value.
       [not found] <bug-91798-4@http.gcc.gnu.org/bugzilla/>
                   ` (3 preceding siblings ...)
  2024-04-06  2:45 ` pinskia at gcc dot gnu.org
@ 2024-04-06  2:46 ` pinskia at gcc dot gnu.org
  4 siblings, 0 replies; 5+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-04-06  2:46 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Depends on|                            |60679

--- Comment #6 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
PR 60679 is the PR about the defect report too.


Referenced Bugs:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60679
[Bug 60679] [DR1647] class specialization not instantiated even though it is a
better match than the primary template

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

end of thread, other threads:[~2024-04-06  2:46 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <bug-91798-4@http.gcc.gnu.org/bugzilla/>
2021-03-08 10:12 ` [Bug c++/91798] Compiler rejects code due to template specialization of auto parameter value redi at gcc dot gnu.org
2021-08-05  6:02 ` pinskia at gcc dot gnu.org
2024-04-06  2:37 ` pinskia at gcc dot gnu.org
2024-04-06  2:45 ` pinskia at gcc dot gnu.org
2024-04-06  2:46 ` pinskia 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).