Closed Bug 623303 Opened 14 years ago Closed 14 years ago

[Clang] expected the class name after '~' to name a destructor in jspropertytree.cpp

Categories

(Core :: JavaScript Engine, defect)

x86_64
macOS
defect
Not set
normal

Tracking

()

RESOLVED FIXED

People

(Reporter: Nomis101, Assigned: brendan)

References

Details

(Whiteboard: fixed-in-tracemonkey)

Clang doesn't build jspropertytree.cpp because of the following error: /Developer/temp/src/mozilla/js/src/jspropertytree.cpp:395:54: error: expected the class name after '~' to name a destructor hash->KidsHash::~KidsHash(); ^ /Developer/temp/src/mozilla/js/src/jspropertytree.cpp:663:26: error: expected the class name after '~' to name a destructor hash->KidsHash::~KidsHash(); ^
Sounds like a Clang bug. The type is a template instantiation that is a class. Cc'ing language lawyers. /be
I think this line should be written: hash->~KidsHash(); While a->B::foo() is generally allowed, I am guessing that, since a destructor may only be called on the most derived type, there is only one valid 'B' and thus the choice is disallowed (but I'd have to break out the standard to be sure :).
Yes, this is an error. See 12.4 Destructors, which gives this example (see the B_alias::~B_alias item): struct B { virtual ̃B() { } }; struct D : B { D() { } }; D D_object; typedef B B_alias; B* B_ptr = &D_object; void f() { D_object.B::~B(); // calls B's destructor B_ptr->~B(); // calls D's destructor B_ptr->~B_alias(); // calls D's destructor B_ptr->B_alias::~B(); // calls B's destructor B_ptr->B_alias::~B_alias(); // error, no B_alias in class B } Since we have: typedef HashSet<js::Shape *, ShapeHasher, SystemAllocPolicy> KidsHash; Our case is effectively the last line, which is an error, or so it seems. A little strange that the language seemingly doesn't resolve typedefs on the right-hand side of an explicit destructor call, but hey, it's C++.
(In reply to comment #2) > I think this line should be written: > > hash->~KidsHash(); Ah yes, that builds with clang without an error. And it builds with gcc4.2 as well.
Good for clang. So MSVC and GCC are both violating the C++ spec? /be
Assignee: general → brendan
(In reply to comment #3) Wow, so you can call not-the-most-derived destructors! Learn something new every day...
Whiteboard: fixed-in-tracemonkey
Status: NEW → RESOLVED
Closed: 14 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.