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++/32402] Error while allocating array of pointers to objects of a pure virtual class


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

--- Comment #11 from Jonathan Wakely <redi at gcc dot gnu.org> 2010-10-31 11:31:01 UTC ---
(In reply to comment #10)
> Ok, I've read the bug report following a report from a friend, and after
> checking various sources I've come to the following conclusion:
> 
> new pure(*[3]) is not valid

That's not what the bug report contains though!

It's "new (pure(*[3]))" with an extra set of parentheses around the type, so
according to the grammar "pure(*[3])" must be parsed as a type-id, there is no
initializer

> When parsed, "new pure(*[3])" is parsed as "new instance of class pure with
> parameter *[3]".

Right, and it's not accepted, see comment 5:

> - "list = new pure(*[3]);" => does not compile

But that's a different case to "new (pure(*[3]))" which is what this PR is
about.

> Anyway I see no logical reason why one would want to put part of its allocation
> into parenthesis.
> 
> "new pure*[3]" should be perfectly acceptable, is easier to read, and is
> accepted by GCC without problems.


That's beside the point, if the grammar is valid then it should be accepted.


> Jonathan Wakely's example with decltype() is non related as decltype() is a new
> compiler keyword, which is valid in this context, but has nothing to do with
> the original problem.

It demonstrates that GCC is happy to allocate an array of pure* using different
syntax, and that the syntax works for declaring an automatic variable.

> Anyway I believe  this bug report should be closed before more people spend
> time looking at C++ references for this.

I disagree, it's a bug, and the code is accepted by other compilers.


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