public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/52321] New: poor diagnostic of invalid cast
@ 2012-02-21  1:36 igodard at pacbell dot net
  2012-02-21 11:18 ` [Bug c++/52321] " redi at gcc dot gnu.org
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: igodard at pacbell dot net @ 2012-02-21  1:36 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52321

             Bug #: 52321
           Summary: poor diagnostic of invalid cast
    Classification: Unclassified
           Product: gcc
           Version: 4.6.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: igodard@pacbell.net


This code:
   class foo;
   class bar {};
   int main() {
       foo* f;
       bar* b = static_cast<bar*>(f);
       return 0;
       }

gets you this:

   s3:~/ootbc/sim$ g++ foo.cc
   foo.cc: In function âint main()â:
   foo.cc:5:30: error: invalid static_cast from type âfoo*â to type âbar*â

The issued diagnostic is correct but not very helpful. The real bug is that
class foo is defined (somewhere else) as class foo : public bar {...}, but the
definitions wasn't imported. A diagnostic like:
   foo.cc: In function âint main()â:
   foo.cc:6:3: error: invalid use of incomplete type âstruct fooâ
   foo.cc:1:7: error: forward declaration of âstruct fooâ
(which is what you put out for -> on an undefined) would be *much* better.


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2015-03-03 10:19 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-02-21  1:36 [Bug c++/52321] New: poor diagnostic of invalid cast igodard at pacbell dot net
2012-02-21 11:18 ` [Bug c++/52321] " redi at gcc dot gnu.org
2012-02-21 15:38 ` igodard at pacbell dot net
2012-02-21 15:59 ` redi at gcc dot gnu.org
2012-02-21 17:41 ` igodard at pacbell dot net
2012-02-22 16:15 ` manu at gcc dot gnu.org
2015-03-03 10:19 ` redi at gcc dot gnu.org

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