------- 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