This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/38612] Vague error diagnostics for pointer-to-member type incompatibility


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=38612

Manuel LÃpez-IbÃÃez <manu at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2014-05-30
                 CC|                            |jason at gcc dot gnu.org,
                   |                            |manu at gcc dot gnu.org
     Ever confirmed|0                           |1

--- Comment #4 from Manuel LÃpez-IbÃÃez <manu at gcc dot gnu.org> ---
I agree the diagnostic could be much better but I'm not fully convinced by your
proposal.

Clang++ says:

pr38612.cc:7:16: error: left hand operand to ->* must be a pointer to class
compatible with the right hand operand, but is 'X'
  return object->*p2m;// fails because X is incomplete
               ^
pr38612.cc:2:8: note: forward declaration of 'X'
struct X;// X derived from Base later but incomplete here
       ^
pr38612.cc:21:16: error: left hand operand to ->* must be a pointer to class
compatible with the right hand operand, but is 'Y *'
  return object->*p2m;// fails because Y is not derived from A
               ^

which to me is only slightly better. 

I think I would like to get:

pr38612.cc:7:16: error: right hand operand 'Base::*' to '->*' is not compatible
with left-hand operand 'X *' because 'X' is not a complete type
  return object->*p2m;// fails because X is incomplete
               ^
pr38612.cc:2:8: note: forward declaration of 'X'
struct X;// X derived from Base later but incomplete here
       ^
pr38612.cc:21:16: error: right hand operand 'Base::*' to '->*' is not
compatible with left-hand operand 'Y *' because 'Y' is not derived from 'Base'
  return object->*p2m;// fails because Y is not derived from A
               ^
pr38612.cc:3:8: note: 'Y' declared here
struct Y {};// Y not derived from Base
       ^

What do you think?

Jason?

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]