[Bug c++/95933] New: pointer variables in template classes admit arbitrary assignments
jaime.a.rosal at gmail dot com
gcc-bugzilla@gcc.gnu.org
Sat Jun 27 04:40:46 GMT 2020
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95933
Bug ID: 95933
Summary: pointer variables in template classes admit arbitrary
assignments
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: jaime.a.rosal at gmail dot com
Target Milestone: ---
I recently found some strange behavior in GCC 9.3 . For some reason pointer
variables in templated classes seem to admit assignments to arbitrary types,
i.e. the following code:
template <int N> struct Bar {
int * E;
void Foo () {
E = new double[1000]; // wait, what?
}
};
Bar<1> T;
compiles without error with 'g++ -c bug.cpp'. This seems to be true for any
combination of types and template parameters.
More information about the Gcc-bugs
mailing list