I had the following issue a couple of days ago when using arm-none-eabi-gcc toolchain on arch linux, which uses gcc13.2 as the gcc version, unlike the toolchain I was using in Ubuntu, I assumed it would be some version stuff so I went to the gcc release page to read the notes: https://gcc.gnu.org/gcc-13/changes.html, but as you will see nothing about redeclaration of templates is mentioned
upon some research I came to this reproducible example:
// compiles fine under gcc 12.3
#include <concepts>
#include <type_traits>
template<typename T>
class Sensor{
public:
int read();
};
template<typename T>
requires std::is_integral_v<T>
int Sensor<T>::read(){
return 1;
}
int main(){
Sensor<int> s;
s.read();
}
//does not compile under gcc 13.2
#include <concepts>
#include <type_traits>
template<typename T>
class Sensor{
public:
int read();
};
template<typename T>
requires std::is_integral_v<T>
int Sensor<T>::read(){
return 1;
}
int main(){
Sensor<int> s;
s.read();
}
Could someone explain why in version 12.3 it is allowed but not in 13.2? Also I'd assume the constrainst enforced in 13.2 should have been a standard de facto way ago
The relevant note is in
gcc/cp/ChangeLog
:12.3 was released before this bugfix was submitted.
The full commit message is: