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

            Bug ID: 115296
           Summary: CTAD fails
           Product: gcc
           Version: 15.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: tiagomacarios at gmail dot com
  Target Milestone: ---

The following code compiles fine with clang and msvc, but fails with gcc.

https://godbolt.org/z/e4dP7rzar
```
#include <span>

template <typename T>
using array_view = std::span<T>;

void fun(std::span<int> s) {
    [[maybe_unused]] auto _1 = std::span{s};
    [[maybe_unused]] auto _2 = array_view{s};
}
```

Error:
```
In file included from <source>:1:
/opt/compiler-explorer/gcc-trunk-20240530/include/c++/15.0.0/span: In function
'void fun(std::span<int>)':
/opt/compiler-explorer/gcc-trunk-20240530/include/c++/15.0.0/span:450:5: error:
size '18446744073709551615' of array exceeds maximum object size
'9223372036854775807'
  450 |     span(_Type(&)[_ArrayExtent]) -> span<_Type, _ArrayExtent>;
      |     ^~~~
/opt/compiler-explorer/gcc-trunk-20240530/include/c++/15.0.0/span:450:10:
error: size '18446744073709551615' of array exceeds maximum object size
'9223372036854775807'
  450 |     span(_Type(&)[_ArrayExtent]) -> span<_Type, _ArrayExtent>;
      |          ^~~~~~~~~~~~~~~~~~~~~~
<source>:8:44: error: class template argument deduction failed:
    8 |     [[maybe_unused]] auto _2 = array_view{s};
      |                                            ^
<source>:8:44: error: call of overloaded 'span(std::span<int>&)' is ambiguous
/opt/compiler-explorer/gcc-trunk-20240530/include/c++/15.0.0/span:464:5: note:
candidate: 'std::span(_Range&&)-> span<typename
remove_reference<ranges::range_reference_t<_Range&> >::type> requires 
__is_deducible (array_view, std::span<typename
std::remove_reference<decltype(*(declval<decltype(std::ranges::__access::__begin((declval<_Container&>)()))&>)())>::type,
18446744073709551615>) [with _Range = span<int>&; typename
remove_reference<ranges::range_reference_t<_Range&> >::type = int;
ranges::range_reference_t<_Range&> = int&]'
  464 |     span(_Range &&)
      |     ^~~~
/opt/compiler-explorer/gcc-trunk-20240530/include/c++/15.0.0/span:54:11: note:
candidate: 'span(std::span<_Type, 18446744073709551615>)-> std::span<_Type,
18446744073709551615> [with T = int]'
   54 |     class span;
      |           ^~~~
/opt/compiler-explorer/gcc-trunk-20240530/include/c++/15.0.0/span:225:7: note:
candidate: 'span(const std::span<_Type, 18446744073709551615>&)->
std::span<_Type, 18446744073709551615> [with T = int]'
  225 |       span(const span&) noexcept = default;
      |       ^~~~
Compiler returned: 1
```
  • [Bug c++/115296] New: CTAD fai... tiagomacarios at gmail dot com via Gcc-bugs

Reply via email to