[Bug c++/85943] New: Template function permits outside access to private variable
achuah at drwsg dot com
gcc-bugzilla@gcc.gnu.org
Mon May 28 03:26:00 GMT 2018
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85943
Bug ID: 85943
Summary: Template function permits outside access to private
variable
Product: gcc
Version: 8.1.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: achuah at drwsg dot com
Target Milestone: ---
This probably should be classified under meta-bug
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=59002
See this example on Godbolt's compiler explorer: https://godbolt.org/g/skvWAt
If the accessing function were not a template function, then GCC correctly
prevents the private access.
If the private member was a function instead of a variable, then GCC correctly
prevents the private access, but only upon instantiation.
Note: in all of these cases, clang will not compile, regardless of whether
there's been an instantiation of the template.
More information about the Gcc-bugs
mailing list