[cfe-commits] Uninitialized data problem...

Paul Curtis plc at rowley.co.uk
Fri Dec 10 10:12:26 PST 2010


Hi,

In NamedDecl*Sema::ActOnFunctionDeclarator(...) in SemaDecl.cpp there is a
path to this, labelled (HACK), where isExplicitSpecialization has not been
initialized.

  bool OverloadableAttrRequired=false; // FIXME: HACK!
  if (!getLangOptions().CPlusPlus) {
    // Perform semantic checking on the function declaration.
    CheckFunctionDeclaration(S, NewFD, Previous, isExplicitSpecialization,
                             Redeclaration, 
                             /*FIXME:*/OverloadableAttrRequired);
    assert((NewFD->isInvalidDecl() || !Redeclaration ||
            Previous.getResultKind() != LookupResult::FoundOverloaded) &&
           "previous declaration set still overloaded");
  }

This is because it, um, it hasn't been (when indexing some of my files--I
don't quite know which yet).

In one path of ActOnFunctionDeclarator() it is left untouched, hence, adding
isExplicitSpecialization = false on this branch solves it.

  if (!getLangOptions().CPlusPlus) {
    // Determine whether the function was written with a
    // prototype. This true when:
    //   - there is a prototype in the declarator, or
    //   - the type R of the function is some kind of typedef or other
reference
    //     to a type name (which eventually refers to a function type).
    ...

Attached a patch against the trunk which fixes it for me.  Not sure whether
this is the right fix or not, but at least I don't come a cropper in the
MSVC debugger any more.

Stylistically, you may wish to set isExplicitSpecialization false with an
initializer.

--
Paul Curtis, Rowley Associates Ltd   http://www.rowley.co.uk
SolderCore arriving Winter 2010!   http://www.soldercore.com

-------------- next part --------------
A non-text attachment was scrubbed...
Name: clang.patch
Type: application/octet-stream
Size: 551 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20101210/26def1da/attachment.obj>


More information about the cfe-commits mailing list