Closed Bug 418170 Opened 16 years ago Closed 16 years ago

gcc-dehydra: templates, incomplete types, and nsTObserverArray.cpp

Categories

(Developer Infrastructure :: Source Code Analysis, defect)

x86
Linux
defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: benjamin, Assigned: taras.mozilla)

Details

Attachments

(1 file)

When processing nsTObserverArray.cpp on mozilla trunk using gcc-dehydra:

BEGIN: process_class
PARAM: c
#1={kind:"class", bases:[{isIncomplete:true, kind:"class", name:"nsTArray<E>"}], members:[{name:"nsAutoTArray<E, 0u>::nsA
utoTArray()", isFunction:true, isConstructor:true, type:{type:{isIncomplete:true, name:"void"}, parameters:[{isPointer:tr
ue, type:#1#}]}, isStatic:true, loc:"/builds/clean-trunk/mozilla/xpcom/glue/nsTArray.h:763:18"}], name:"nsAutoTArray<E, 0
u>"}
END: process_class

I'm not sure whether process_class is supposed to be called at all for non-instantiated template classes (I thought it wasn't).

But nsAutoTArray<E, 0u> is not a complete class... and it's even worse that it's supposedly a complete class with an incomplete base (just can't happen!).

I have an explicit check+warning for this case right now, but I'm afraid it is a sign of some deeper problem. I can attach the .ii file if you need, but since it's reproducable with CVS trunk or mozilla-central I figured it probably wasn't necessary.
I'm looking into this.
OK, it's caused by a partial specialization (if I've got the C++ terminology right). Dehydra seems to be calling process_class on partial specializations, as if they were instantiations. A reduced test case follows. I'll see if I can figure out a patch.

template<typename T, int e>
class Array {
  T a[e];
};

template<typename E>
class Array<E, 0> {
  E *a;
};
Attached patch Proposed patchSplinter Review
Well, here's my attempt at a fix. I added a check for specializations. See cp/cp-tree.h for the def of the macro I used.
Attachment #304361 - Attachment is patch: true
Attachment #304361 - Attachment mime type: application/octet-stream → text/plain
Comment on attachment 304361 [details] [diff] [review]
Proposed patch

>+  int template_status = CLASSTYPE_USE_TEMPLATE(c);
>+  if (template_status == 2) return;

No need for the extra variable here. Please add your testcase to the patch too.
Corrections made and fix pushed.
Status: NEW → RESOLVED
Closed: 16 years ago
Resolution: --- → FIXED
Product: Core → Firefox Build System
Product: Firefox Build System → Developer Infrastructure
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: