[Bug c++/116144] New: Invalid array size value assigned with dependent name in parameter of template function cannot be detected by g++
rush102333 at gmail dot com
gcc-bugzilla@gcc.gnu.org
Tue Jul 30 14:25:46 GMT 2024
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116144
Bug ID: 116144
Summary: Invalid array size value assigned with dependent name
in parameter of template function cannot be detected
by g++
Product: gcc
Version: 13.2.0
Status: UNCONFIRMED
Keywords: accepts-invalid
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: rush102333 at gmail dot com
Target Milestone: ---
Consider the following code:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
template<typename T> void f(int a[(int)T()]);
void g() { f<char[10]>(0); }
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
There should be something wrong with "f<char[10]>" because the template
argument passed to "f" is an array value and cannot be
value-initialized, for instance, in the form of "char[10]()".
Both EDG and clang reject the code, but gcc accepts it. This will only happen
when the index value is related to a dependent name.
https://godbolt.org/z/GG4W5G755
More information about the Gcc-bugs
mailing list