C++ Logo

std-discussion

Advanced search

Understanding CWG 1396

From: Brian Ehlert <bjehlert_at_[hidden]>
Date: Fri, 15 Nov 2019 10:56:19 -0800
Per the consensus for CWG 1396
<http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_active.html#1396>, should
the following code compile?

https://godbolt.org/z/Rjv9Xq

Per [temp.inst]/12 <http://eel.is/c++draft/temp.inst#12>, default arguments
are not instantiated unless needed and [temp.inst]/10
<http://eel.is/c++draft/temp.inst#10> states "an implementation should not
instantiate a.... non-virtual member function.... unless such instantiation
is required."

In this example, the default constructor of A is never needed and therefore
I believe CWG 1396 is saying it shouldn't be instantiated. Is this a
correct interpretation?

Both Clang 9 and GCC 9.2 reject this code but MSVC 19.22 allows it. I
understand the issue still has drafting status but I'm looking for
clarification on whether this scenario is covered and whether I understand
the issue correctly.

Thanks,
Brian Ehlert

Received on 2019-11-15 12:58:51