https://bugs.llvm.org/show_bug.cgi?id=39663

            Bug ID: 39663
           Summary: Class template argument deduction with deduced type
                    fails when accessing member
           Product: clang
           Version: 7.0
          Hardware: PC
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++'17
          Assignee: [email protected]
          Reporter: [email protected]
                CC: [email protected], [email protected],
                    [email protected], [email protected]

Try to compile the following c++ program:

  template <class T>
  struct C {
    C(T) {}
    int a;
  };

  template <class T>
  int foo(T v) {
    return C{v}.a; // <----
  }

  int main() {
    foo(4);
  }

The line marked above fails with the error:

error: member reference base type 'C' is not a structure or union
    return (C{v}).a;
           ~~~~~~^~

Note that the following all work fine:

  template <class T>
  C<T> foo(T v) {
    return C{v};
  }

and

  int foo(int v) {
    return C{v}.a;
  }

and

  C{4}.a;

I tried this also on a recent trunk build (trunk 346600)

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
[email protected]
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to