Today I came across a very nasty bug, here is the MWE:
Contrary to my expectations, " Default " is printed. Of course, the code is faulty because the inherited constructors of Z try to initialize X without specifying how to construct Y (*) . But still, shouldn't the compiler complain? What is the rationale for the default constructor, Y (and subsequently X ), being invoked completely ignoring my parameter 3 ? Is this documented somewhere in the standard? Or is this a bug in my compiler?
My environment is gcc version 6.2.1 20160916 (Red Hat 6.2.1-2) . A compiler warning is not generated even with -Weffc++ -Wall -Wextra -pedantic .
c ++ gcc inheritance constructor
The vee
source share