[LLVMbugs] [Bug 11666] New: local/unnamed types as template arguments extension in c++98 is non-conforming

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Tue Dec 27 18:52:55 PST 2011


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

             Bug #: 11666
           Summary: local/unnamed types as template arguments extension in
                    c++98 is non-conforming
           Product: clang
           Version: trunk
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: C++
        AssignedTo: unassignedclangbugs at nondot.org
        ReportedBy: richard-llvm at metafoo.co.uk
                CC: dgregor at apple.com, llvmbugs at cs.uiuc.edu
    Classification: Unclassified


template<typename T> int f(T t) { return 1; } // #1
int f(int n) { return 2; } // #2
int g() {
  enum { E };
  return f(E);
}

In C++11 mode, g() will return 1.

In C++98 mode, it looks like g() must return 2, because #1 has (what looks
like) a substitution failure (since it attempts to use an unnamed local type as
a template argument). However, when built with clang in C++98 mode, it returns
1, and produces an ExtWarn diagnostic. This both generates wrong code (and
potentially rejects valid if instantiating f fails), and causes -Werror builds
to fail.

It's not entirely clear that clang is at fault here: while clang calls #1 and
g++ calls #2, EDG produces a hard error (using local type as template
argument). However, if clang's ExtWarn is upgraded to an Error (as it was prior
to this extension being added), we accept this code and call #2.

-- 
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.



More information about the llvm-bugs mailing list