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.