C++ Logo


Advanced search

Subject: Understanding CWG 1396
From: Brian Ehlert (bjehlert_at_[hidden])
Date: 2019-11-15 12:56:19

Per the consensus for CWG 1396
<http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_active.html#1396>, should
the following code compile?


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.

Brian Ehlert

STD-DISCUSSION list run by std-discussion-owner@lists.isocpp.org

Older Archives on Google Groups