[LLVMbugs] [Bug 22038] New: Members of current instantiation should be non-dependent, but are mostly treated as dependent

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Sat Dec 27 05:01:05 PST 2014


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

            Bug ID: 22038
           Summary: Members of current instantiation should be
                    non-dependent, but are mostly treated as dependent
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++11
          Assignee: unassignedclangbugs at nondot.org
          Reporter: harald at gigawatt.nl
                CC: dgregor at apple.com, llvmbugs at cs.uiuc.edu
    Classification: Unclassified

Consider this test program, which uses ADL to detect whether expressions are
treated as dependent or as non-dependent. Non-dependent expressions are looked
up at template definition time, so find the void f(const char *s, ...)
function. Dependent expressions are looked up at template instantiation time
with ADL, and find the void f(const char *s, S1) function.

    #include <cstdio>

    void f(const char *s, ...) { std::printf("%s: non-dependent\n", s); }

    struct S1 { };

    template <typename T>
    struct S2 {
      static S1 a;
      static S1 b() { return {}; }
      template <typename U>
      static U c() { return {}; }
      static void z() {
        f("S1()", S1());
        f("T()", T());
        f("a", a);
        f("b()", b());
        f("c<T>()", c<T>());
        f("c<S1>()", c<S1>());
        f("decltype(b())()", decltype(b())());
      }
    };

    void f(const char *s, S1) { std::printf("%s: dependent\n", s); }

    int main() {
      S2<S1>::z();
    }

The output with r223387
(http://llvm.org/builds/downloads/LLVM-3.6.0-r223387-win32.exe from 5 December)
is:

    S1(): non-dependent
    T(): dependent
    a: non-dependent
    b(): non-dependent
    c<T>(): dependent
    c<S1>(): dependent
    decltype(b())(): dependent

Compilation flags used for testing: -std=c++11 -pedantic -Wall. No warnings or
errors are given.

The ones involving T are sanity checks: they're obviously dependent. All the
other ones should be non-dependent. The difference between b() and
decltype(b())() is particularly troubling to me: b() is treated as
non-dependent when used directly, and decltype(expr) is supposed to be
dependent if and only if expr is type-dependent, and T() is supposed to be
type-dependent if and only if T is dependent, yet decltype(b())() is treated as
dependent.

-- 
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/20141227/776e7f71/attachment.html>


More information about the llvm-bugs mailing list