public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/21746] New: Compiler will not create references of abstract types
@ 2005-05-25  2:33 vircum at yahoo dot com
  2005-05-25  2:36 ` [Bug c++/21746] " pinskia at gcc dot gnu dot org
  0 siblings, 1 reply; 2+ messages in thread
From: vircum at yahoo dot com @ 2005-05-25  2:33 UTC (permalink / raw)
  To: gcc-bugs

Consider the code:
class A {
public:
        virtual void foo() = 0;
};

class B : public A {
public:
        virtual void foo() {}
};

int main()
{
        const A &a = B(); // <-- here
        return 0;
}


in g++-4.0, as it comes pre-installed on Mac 10.4, I get the error:
$ g++ -c g++4-bug.cc
g++4-bug.cc: In function `int main()':
g++4-bug.cc:15: error: cannot allocate an object of abstract type 'A'
g++4-bug.cc:3: note:   because the following virtual functions are pure within 'A':
g++4-bug.cc:5: note:  virtual void A::foo()

However, this code compiles without complaint on the g++-3.4 that comes
preinstalled on this system.  I don't know whether this has been fixed since
gcc-4.0, but it doesn't seem to me like there's any reason for gcc to reject
this code.

Thanks,
Michael

-- 
           Summary: Compiler will not create references of abstract types
           Product: gcc
           Version: 4.0.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: vircum at yahoo dot com
                CC: gcc-bugs at gcc dot gnu dot org
 GCC build triplet: powerpc-apple-darwin8.1.0
  GCC host triplet: powerpc-apple-darwin8.1.0
GCC target triplet: powerpc-apple-darwin8.1.0


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


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

* [Bug c++/21746] Compiler will not create references of abstract types
  2005-05-25  2:33 [Bug c++/21746] New: Compiler will not create references of abstract types vircum at yahoo dot com
@ 2005-05-25  2:36 ` pinskia at gcc dot gnu dot org
  0 siblings, 0 replies; 2+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-05-25  2:36 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2005-05-25 02:35 -------
This is not a bug in the FSF released GCC, only Apple's report it to them.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |INVALID


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


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

end of thread, other threads:[~2005-05-25  2:35 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-05-25  2:33 [Bug c++/21746] New: Compiler will not create references of abstract types vircum at yahoo dot com
2005-05-25  2:36 ` [Bug c++/21746] " pinskia at gcc dot gnu dot 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).