[llvm-bugs] [Bug 39663] New: Class template argument deduction with deduced type fails when accessing member

via llvm-bugs llvm-bugs at lists.llvm.org
Wed Nov 14 11:58:06 PST 2018


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: unassignedclangbugs at nondot.org
          Reporter: bmburstein at gmail.com
                CC: blitzrakete at gmail.com, erik.pilkington at gmail.com,
                    llvm-bugs at lists.llvm.org, richard-llvm at metafoo.co.uk

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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20181114/6d728b7c/attachment.html>


More information about the llvm-bugs mailing list