[llvm-bugs] [Bug 38578] New: C++ friend Constructor with Templates Not Recognized
via llvm-bugs
llvm-bugs at lists.llvm.org
Wed Aug 15 07:08:39 PDT 2018
https://bugs.llvm.org/show_bug.cgi?id=38578
Bug ID: 38578
Summary: C++ friend Constructor with Templates Not Recognized
Product: clang
Version: unspecified
Hardware: PC
OS: All
Status: NEW
Severity: normal
Priority: P
Component: C++
Assignee: unassignedclangbugs at nondot.org
Reporter: mattmiller1 at gmail.com
CC: dgregor at apple.com, llvm-bugs at lists.llvm.org
Noticed the following behavior which isn't clear to me is standard compliant:
1. non-template friend function (not constructor): compiles in gcc and clang
2. non-template friend constructor: compiles in gcc and clang
3. template friend function (not constructor): compiles in gcc and clang
4. template friend constructor: compiles in gcc , but not clang
(compiled in clang 3.0.0 but not clang 3.1+)
Here is an example (use -DUSE_TEMPLATE to control whether the template
or non-template code is compiled):
https://godbolt.org/g/FT7Mzj
In the clang case for (4), it gives an error as if the friend
declaration was never made.
Looking at a C++ standard:
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2017/n4659.pdf
It looks like section 14.3.5 gives an explicit example of a
non-template friend constructor being allowed. In 17.5.4, it didn't
look like there was anything to indicate template friend constructors
are treated different than template friend non-constructor functions,
but maybe I'm missing a subtle point in that section or elsewhere.
If there is a reason why (4) is not allowed by the standard but (3)
is, it might be good to have a more specific compile error message
indicating that.
--
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/20180815/cfe6cb17/attachment.html>
More information about the llvm-bugs
mailing list