public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/32410] New: Const functions in template don't give access errors with this until instantiated.
@ 2007-06-19 22:38 coppro at users dot sourceforge dot net
2007-06-19 23:13 ` [Bug c++/32410] " pinskia at gcc dot gnu dot org
0 siblings, 1 reply; 2+ messages in thread
From: coppro at users dot sourceforge dot net @ 2007-06-19 22:38 UTC (permalink / raw)
To: gcc-bugs
If you create a const member function to a template class, it seems to be able
to change a non-mutable member of the function by using the this pointer. The
following illegal code compiles:
template <typename T>
class Class
{
unsigned int i;
public:
void foo () const
{
this->i++;
}
};
However, if Class<whatever>::foo is instantiated, then it gives an error for
changing the constant data member. However, if you remove the "this->" line,
the access errors occur even without an instantion. This is inconsistent
behavior. They should both cause errors at the same point.
--
Summary: Const functions in template don't give access errors
with this until instantiated.
Product: gcc
Version: 4.1.2
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: coppro at users dot sourceforge dot net
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32410
^ permalink raw reply [flat|nested] 2+ messages in thread
* [Bug c++/32410] Const functions in template don't give access errors with this until instantiated.
2007-06-19 22:38 [Bug c++/32410] New: Const functions in template don't give access errors with this until instantiated coppro at users dot sourceforge dot net
@ 2007-06-19 23:13 ` pinskia at gcc dot gnu dot org
0 siblings, 0 replies; 2+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2007-06-19 23:13 UTC (permalink / raw)
To: gcc-bugs
------- Comment #1 from pinskia at gcc dot gnu dot org 2007-06-19 23:13 -------
This is correct as "*this" is dependent so the compiler cannot resolve that
until instantation time so this is not a bug.
>This is inconsistent behavior.
Yes but i here is not depdendent. While this->i is.
--
pinskia at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution| |INVALID
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32410
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2007-06-19 23:13 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-06-19 22:38 [Bug c++/32410] New: Const functions in template don't give access errors with this until instantiated coppro at users dot sourceforge dot net
2007-06-19 23:13 ` [Bug c++/32410] " pinskia at gcc dot gnu dot org
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).