[LLVMbugs] [Bug 16014] New: -fms-compatibility should diagnose failed lookups in the presence of a dependent base

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Wed May 15 08:24:19 PDT 2013


http://llvm.org/bugs/show_bug.cgi?id=16014

            Bug ID: 16014
           Summary: -fms-compatibility should diagnose failed lookups in
                    the presence of a dependent base
           Product: clang
           Version: unspecified
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: normal
          Priority: P
         Component: Frontend
          Assignee: unassignedclangbugs at nondot.org
          Reporter: reid.kleckner at gmail.com
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

Created attachment 10513
  --> http://llvm.org/bugs/attachment.cgi?id=10513&action=edit
minimal dependent base lookup failure test case

This is a variation on the old "unqualified lookup in dependent base" problem. 
Normally clang errors out on code like the following, but in -fms-compatibility
mode, it fails to instantiate the method and actually makes it to codegen
without crashing or erroring out.  Eventually I get a link error because nobody
else creates this instantiation.

$ cat min_etw.cc
template <int N> struct DepBase {
  int header; // Commenting out gives the same result with -fms-compatibility.
};
template <int N> struct Depends : public DepBase<N> {
  int *get() { return &header; }  // header does not resolve
};
int *foo() {
  Depends<5> event;
  return event.get();
}

$ clang -cc1 -fms-extensions -triple i686-pc-linux min_etw.cc -emit-llvm -o
t.ll
min_etw.cc:4:25: error: use of undeclared identifier 'header'
  void *get() { return &header; }  // header does not resolve
                        ^
1 error generated.
# This is correct, it's part of the FAQ:
# http://clang.llvm.org/compatibility.html#dep_lookup_bases

$ clang -cc1 -fms-compatibility -triple i686-pc-linux min_etw.cc -emit-llvm -o
t.ll
# Exit code 0 and no diagnostic.

$ grep '_Z.*get' t.ll
  %call = call i32* @_ZN7DependsILi5EE3getEv(%struct.Depends* %event)
declare i32* @_ZN7DependsILi5EE3getEv(%struct.Depends*) #1
# get is declared, not defined.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20130515/93c4cf40/attachment.html>


More information about the llvm-bugs mailing list