Почему clang не компилирует этот код в отличии от gcc
От: niralex  
Дата: 18.03.23 17:51
Оценка:
#include <iostream>
#include <array>

using namespace std;

template<const int *ptr>
constexpr const int *Test()
{
    return ptr + 1;
}

constexpr array<int, 3> ar{1, 2, 3};

int main()
{
    // clang version 15.0.7 - Compile Error!
    // gcc 12.2.0  - ok!!
    constexpr auto x = Test<ar.data()>(); // 1

    cout << *x << endl;
    return 0;
}


Компилятор clang выдает маловразумительные сообщения:
main.cpp|18|error: no matching function for call to 'Test'|
main.cpp|7|note: candidate template ignored: invalid explicitly-specified argument for template parameter 'ptr'|

Как можно минимально поправить код, чтобы и clang и gcc компилировали?
с++20 clang template constexpr
 
Подождите ...
Wait...
Пока на собственное сообщение не было ответов, его можно удалить.