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++/52321] New: poor diagnostic of invalid cast


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.


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