10

Intel C++ compiler (Version 16.0.3.207 Build 20160415) seems to drop the explicit specifier when the constructor of the base class is inherited with using. Is this a bug?

struct B
{
    explicit B(int) { }
};

struct D : B
{
    using B::B;
};

B b = 1; // Not OK, fine
D d = 1; // Not OK with Microsoft C++ and GCC, but OK with Intel C++
Cœur
  • 37,241
  • 25
  • 195
  • 267
Evg
  • 25,259
  • 5
  • 41
  • 83
  • This is certainly supposed to be a bug. Inherited constructors are just exposed with the "using" directive so it should be right the same call as in the base class. – Argenet Jan 05 '17 at 22:15
  • The only thing I found, besides the definition of what an explicit constructor is: "If a using-declaration names a constructor (3.4.3.1), it implicitly declares a set of constructors in the class in which the using-declaration appears (12.9)" That's it. I see nothing explicit (pun not intended) that suggests one or the other behavior is correct. – Sam Varshavchik Jan 05 '17 at 22:19

1 Answers1

7

I believe that the appropriate wording from the standard is the following (n4296, 12.9 Inheriting constructors):

...

The constructor characteristics of a constructor or constructor template are

(2.1) — the template parameter list (14.1), if any,

(2.2) — the parameter-type-list (8.3.5), and

(2.3) — absence or presence of explicit (12.3.1).

For each non-template constructor in the candidate set of inherited constructors other than a constructor having no parameters or a copy/move constructor having a single parameter, a constructor is implicitly declared with the same constructor characteristics unless there is a user-declared constructor with the same signature in the complete class where the using-declaration appears or the constructor would be a default, copy, or move constructor for that class.

...

So most probably it is a bug in the Intel C++ compiler.

Edgar Rokjān
  • 17,245
  • 4
  • 40
  • 67
  • N4296 is a C++17 draft. N4140 is almost exactly the current standard. In N4140 there is a (2.4) point in this section – M.M Jan 05 '17 at 22:48
  • @M.M what do you mean? – haelix Dec 31 '18 at 17:55
  • @haelix exactly what I said ... what did you find unclear? – M.M Jan 01 '19 at 08:34
  • @M.M it seemed to me you were implying that the (2.4) point was significantly changing the answer to the question, but without quoting it, which left me wondering. But perhaps not. – haelix Jan 01 '19 at 20:11
  • @haelix no it was just evidence to the fact of N4296 differing from N4140 , my comment relates to the claim of n4296 as being the standard – M.M Jan 01 '19 at 22:32