http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44499
--- Comment #14 from Jonathan Wakely <redi at gcc dot gnu.org> 2011-03-04 11:23:41 UTC --- (In reply to comment #13) > (In reply to comment #12) > > Manu, can we close this? > > @Jonathan > > I still think that the messages of Comeau and Clang are better than GCC's. I > will try for 4.7 to produce a patch to change the message to be like: > > error: default initialization of const object 'g_d' requires a user-provided > default constructor [-fpermissive] > note: 'const class D' has no user-provided default constructor > > Do you agree? Sure, if you still plan to improve it let's definitely keep it open. > (I'd like to keep the note to jump to the declaration of class D). Ah yes, that's useful. In the spirit of providing "fix it" hints, I think the EDG diagnostic is better. There are two ways to avoid the error: 1) Add a default constructor. This changes the type in non-trivial ways with potentially large side-effects in terms of POD-ness, affecting all users of the code and requiring recompilation. It's not even possible for classes defined in third-party headers. 2) Use an initializer. This doesn't change the type and is a purely local change. The second option is probably the right one in most cases :) "Expert" users who know what they're doing can choose to alter the class, but I don't think we should suggest they do so. How about this: error: Const object 'g_d' requires an initializer [-fpermissive] note: 'const class D' has no user-provided default constructor The error refers to the variable's location and says an initializer is needed. The note refers to the class' location and says it has no default constructor.