Issue 169712
Summary clang 18.1 c++ front-end regression: not recognizing enum members of a template structure
Labels clang
Assignees
Reporter blu
    The following code last compiled successfully in clang 17.0.1 (last version tried) and stopped compiling in clang 18.1.0 (first version noticed to fail) when using `-std=c++11 -Wall -Wno-unused -Werror`:

```
#include <istream>
#include <limits>

template < typename T >
struct A {
    enum { dimension = 2 };
};

A<int> a;
int arr[A<int>::dimension]; // OK
int brr[a.dimension]; // OK

template < typename SCALAR_T >
inline std::istream&
operator >>(
	std::istream& str,
	A< SCALAR_T >& v)
{
	float temp[v.dimension]; // not OK?

	for (size_t i = 0; i < v.dimension; ++i)
		temp[i] = std::numeric_limits< float >::quiet_NaN();

	return str;
}

void foo(std::istream &str)
{
	A<float> a;
	str >> a;
}
```
godbolt.org: https://godbolt.org/z/7c9xE6KEE


clang diagnostics message: `function parameter 'v' with unknown value cannot be used in a constant _expression_`
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to