[cfe-dev] C++ friend Constructor with Templates

Matt Miller via cfe-dev cfe-dev at lists.llvm.org
Wed Sep 5 08:01:18 PDT 2018


On Tue, Sep 4, 2018 at 10:27 PM, John McCall <rjmccall at apple.com> wrote:

>
>
> On Aug 6, 2018, at 12:44 PM, Matt Miller via cfe-dev <
> cfe-dev at lists.llvm.org> wrote:
>
> I was wondering if the following clang behavior is expected/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.
>
>
> No, it looks like a bug to me.  Would you mind filing it?
>   https://bugs.llvm.org
>
> John.
>

Opened bug 38578:

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

-Matt
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20180905/b7fe87f7/attachment.html>


More information about the cfe-dev mailing list