public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/114884] New: GCC rejects valid deduction using deduction guide
@ 2024-04-29  4:58 jlame646 at gmail dot com
  0 siblings, 0 replies; only message in thread
From: jlame646 at gmail dot com @ 2024-04-29  4:58 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 114884
           Summary: GCC rejects valid deduction using deduction guide
           Product: gcc
           Version: 15.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: jlame646 at gmail dot com
  Target Milestone: ---

The following valid program afaik is rejected by gcc but accepted by clang and
msvc: https://godbolt.org/z/85sjenzrn

```
#include <cassert>
#include <iostream>
#include <array>
#include <vector>
#include <concepts>
#include <type_traits>

template<typename C>
class Vec
{
    C elems;
public:

    Vec(const std::initializer_list<C>& init)
    {

    }

};
template<typename T> Vec(const std::initializer_list<T>& vec) ->
Vec<std::array<T, vec.size()>>;
template<typename C>
Vec(C) -> Vec<C>;

int main()
{
    Vec v0({1, 4, 7});
}
```

GCC says

```
<source>:20:93: error: template argument 2 is invalid
   20 | template<typename T> Vec(const std::initializer_list<T>& vec) ->
Vec<std::array<T, vec.size()>>;
      |                                                                        
                    ^
<source>:20:94: error: template argument 2 is invalid
   20 | template<typename T> Vec(const std::initializer_list<T>& vec) ->
Vec<std::array<T, vec.size()>>;
      |                                                                        
                     ^~
<source>:20:94: error: template argument 2 is invalid
<source>:20:94: error: template argument 2 is invalid
<source>:20:70: error: invalid template-id
   20 | template<typename T> Vec(const std::initializer_list<T>& vec) ->
Vec<std::array<T, vec.size()>>;
      |                                                                     
^~~
<source>:20:75: error: template argument 1 is invalid
   20 | template<typename T> Vec(const std::initializer_list<T>& vec) ->
Vec<std::array<T, vec.size()>>;
      |                                                                        
  ^~~~~
<source>:20:75: error: template argument 1 is invalid
<source>:20:75: error: template argument 1 is invalid
<source>:20:75: error: template argument 1 is invalid
<source>:20:66: error: invalid template-id
   20 | template<typename T> Vec(const std::initializer_list<T>& vec) ->
Vec<std::array<T, vec.size()>>;
      |                                                                  ^~~
<source>:20:96: error: missing template arguments before ';' token
   20 | template<typename T> Vec(const std::initializer_list<T>& vec) ->
Vec<std::array<T, vec.size()>>;
      |                                                                        
                       ^
<source>:20:96: error: expected '>' before ';' token
<source>:20:96: error: trailing return type 'Vec<...auto...>' of deduction
guide is not a specialization of 'Vec<C>'
<source>: In function 'int main()':
<source>:26:9: error: 'Vec<...auto...> v0' has incomplete type
   26 |     Vec v0({1, 4, 7});
      |         ^~
Compiler returned: 1
```

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2024-04-29  4:58 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-04-29  4:58 [Bug c++/114884] New: GCC rejects valid deduction using deduction guide jlame646 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).