This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/26698] [4.0/4.1/4.2/4.3 Regression] g++ accepts const-incorrect code due to conversion function
- From: "mmitchel at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 7 Sep 2007 23:50:24 -0000
- Subject: [Bug c++/26698] [4.0/4.1/4.2/4.3 Regression] g++ accepts const-incorrect code due to conversion function
- References: <bug-26698-8718@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #10 from mmitchel at gcc dot gnu dot org 2007-09-07 23:50 -------
It looks to me that the change I made in Comment #5 was just an optimization;
the warning was already conditionalized on warn_conversion. I just
short-circuited the checking sooner. Declaring the conversion function is not
illegal, so I think it's OK that we only warn conditionally.
It's true that we should never use the conversion function. The error we're
getting now is just a consequence of the body of the conversion function; if we
put "return *new X" in there, it would compile file, and we probably wouldn't
get an error about the program, even though it's still invalid.
So, I do think that there's a bug somewhere; we shouldn't be considering this
conversion operator when calling add_one.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=26698