public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "redi at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/44499] No default constructor available
Date: Fri, 04 Mar 2011 11:23:00 -0000	[thread overview]
Message-ID: <bug-44499-4-AJxfcaYmZ0@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-44499-4@http.gcc.gnu.org/bugzilla/>

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.


  parent reply	other threads:[~2011-03-04 11:23 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <bug-44499-4@http.gcc.gnu.org/bugzilla/>
2011-03-03 22:28 ` dirtyepic at gentoo dot org
2011-03-03 23:14 ` redi at gcc dot gnu.org
2011-03-03 23:16 ` redi at gcc dot gnu.org
2011-03-04 10:02 ` manu at gcc dot gnu.org
2011-03-04 11:23 ` redi at gcc dot gnu.org [this message]
2011-03-04 11:25 ` redi at gcc dot gnu.org
2011-03-17 11:46 ` dirtyepic at gentoo dot org
2011-03-17 11:46 ` redi at gcc dot gnu.org
2011-03-19 20:05 ` redi at gcc dot gnu.org
2011-09-25 11:46 ` [Bug c++/44499] [4.7 Regression?] " paolo.carlini at oracle dot com
2011-09-25 14:23 ` redi at gcc dot gnu.org
2011-09-25 14:39 ` [Bug c++/44499] " paolo.carlini at oracle dot com
2014-02-16 10:02 ` jackie.rosen at hushmail dot com
2010-06-11  9:10 [Bug c++/44499] New: " piotr dot wyderski at gmail dot com
2010-06-11  9:26 ` [Bug c++/44499] " redi at gcc dot gnu dot org
2010-06-11 10:28 ` redi at gcc dot gnu dot org
2010-06-11 10:53 ` manu at gcc dot gnu dot org
2010-06-11 11:01 ` piotr dot wyderski at gmail dot com
2010-06-11 11:12 ` manu at gcc dot gnu dot org
2010-06-11 11:12 ` manu at gcc dot gnu dot org
2010-06-11 11:14 ` manu at gcc dot gnu dot org
2010-07-02  8:09 ` manu at gcc dot gnu dot org
2010-07-02  8:12 ` pluto at agmk dot net
2010-07-02  9:15 ` manu at gcc dot gnu dot org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-44499-4-AJxfcaYmZ0@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).