public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/32402]  New: Error while allocating array of pointers to objects of a pure virtual class
@ 2007-06-19 14:45 p dot vestjens at gmail dot com
  2007-06-19 14:47 ` [Bug c++/32402] " p dot vestjens at gmail dot com
                   ` (4 more replies)
  0 siblings, 5 replies; 15+ messages in thread
From: p dot vestjens at gmail dot com @ 2007-06-19 14:45 UTC (permalink / raw)
  To: gcc-bugs

The compiler thinks we're allocating the actual abstract objects instead of an
array of pointers and reports the following error: "cannot allocate an object
of abstract type '...'". Since we're actual allocating an array of pointers,
this should not be an error.

The following code (reproduce.cpp) demonstrates the problem:

class pure
{
public:
  pure() {}
  virtual bool isPure () = 0;
};

class notPure : public pure
{
public:
  notPure() {}
  virtual bool isPure () { return false; };
};

int main ()
{
  pure ** list;
  list = new (pure (*[3]));
  for (int i = 0; i  < 3; i ++) {
    list [i] = new notPure();
  }
}

The error is reported on line 18 "list = new (pure (*[3]));".

gcc -v results in:
Using built-in specs.
Target: i686-linux
Configured with: ../gcc-4.1.1/configure
--prefix=/p/TargetPlatforms/x86-Linux-cdk/cross-gcc/build/tools
--target=i686-linux --build=i686-pc-mingw32 --host=i686-pc-mingw32
--disable-multilib
--with-local-prefix=/p/TargetPlatforms/x86-Linux-cdk/cross-gcc/build/tools
--with-system-zlib --disable-libunwind-exceptions --disable-nls --enable-shared
--enable-languages=c,c++ --enable-__cxa_atexit --enable-c99 --enable-long-long
--enable-threads=posix --enable-win32-registry=oce-gcc4.1.1-glibc2.5
Thread model: posix
gcc version 4.1.1

We're cross compiling from Windows to Linux.
The command line is very basic: "gcc reproduce.cpp"
This results in the following compiler output:

reproduce.cpp: In function 'int main()':
reproduce.cpp:18: error: cannot allocate an object of abstract type 'pure'
reproduce.cpp:2: note:   because the following virtual functions are pure
within 'pure':
reproduce.cpp:5: note:  virtual bool pure::isPure()

The preprocessed file looks as follows:

# 1 "reproduce.cpp"
# 1 "<built-in>"
# 1 "<command line>"
# 1 "reproduce.cpp"
class pure
{
public:
  pure() {}
  virtual bool isPure () = 0;
};

class notPure : public pure
{
public:
  notPure() {}
  virtual bool isPure () { return false; };
};

int main ()
{
  pure ** list;
  list = new (pure (*[3]));
  for (int i = 0; i < 3; i ++) {
    list [i] = new notPure();
  }
}


-- 
           Summary: Error while allocating array of pointers to objects of a
                    pure virtual class
           Product: gcc
           Version: 4.1.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: p dot vestjens at gmail dot com


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


^ permalink raw reply	[flat|nested] 15+ messages in thread
[parent not found: <bug-32402-4@http.gcc.gnu.org/bugzilla/>]

end of thread, other threads:[~2014-08-10  8:47 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-06-19 14:45 [Bug c++/32402] New: Error while allocating array of pointers to objects of a pure virtual class p dot vestjens at gmail dot com
2007-06-19 14:47 ` [Bug c++/32402] " p dot vestjens at gmail dot com
2007-11-12 15:06 ` gcc at waisse dot org
2007-11-12 15:42 ` gcc at waisse dot org
2007-11-12 19:41 ` zackw at panix dot com
2007-11-13 13:38 ` p dot vestjens at gmail dot com
     [not found] <bug-32402-4@http.gcc.gnu.org/bugzilla/>
2010-10-28 17:21 ` redi at gcc dot gnu.org
2010-10-28 17:30 ` redi at gcc dot gnu.org
2010-10-28 17:44 ` redi at gcc dot gnu.org
2010-10-30 11:47 ` redi at gcc dot gnu.org
2010-10-31  7:34 ` mark at tibanne dot com
2010-10-31 11:31 ` redi at gcc dot gnu.org
2010-10-31 11:59 ` gcc at waisse dot org
2010-10-31 12:42 ` redi at gcc dot gnu.org
2014-08-10  8:47 ` paolo.carlini at oracle dot com

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