<div class="gmail_quote">On Tue, Jul 10, 2012 at 8:14 PM, John McCall <span dir="ltr"><<a href="mailto:rjmccall@apple.com" target="_blank">rjmccall@apple.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div>On Jul 10, 2012, at 7:07 PM, Seth Cantrell wrote:<br>
> I'm trying to figure out against whom to file a bug.<br>
><br>
> This code is parsed differently between Clang, VC++, Comeau, and GCC.<br>
><br>
> struct A {<br>
> A() {}<br>
> A(int) {}<br>
> };<br>
><br>
> struct B : A {<br>
> void init(int i);<br>
> };<br>
><br>
> void B::init(int i) {<br>
> {<br>
> A::A(i); // what is this supposed to parse as?<br>
> }<br>
> }<br>
><br>
> int main() {<br>
> B b;<br>
> b.init(2);<br>
> }<br>
><br>
> Clang and an earlier version of GCC parse it a variable declaration, Comeau and current gcc parse it as an illegal constructor call (but since it's illegal is that constructor really "an acceptable lookup result" according to §<a href="http://3.4.3.1/2?" target="_blank">3.4.3.1/2?</a>), and VC++ seems to parse it as constructing a temporary (which it seems hard to fathom how because if A::A is a constructor name then it's not legal to call and does not 'return' a temporary object, but if A::A is a type name then this is a variable declaration).<br>
<br>
</div>The standard doesn't precisely define "acceptable lookup result", but I think (given the example in the immediate context of an elaborated-type-specifier) that an acceptable lookup result is one which is not ignored by the kind of lookup being performed.</blockquote>
<div><br></div><div>Core issue 1310 covers this unfortunately-unclear wording. One problem with the current statement of the rule is that we must perform two different kinds of lookup: we must look A::A up as a simple-type-specifier in case it's a decl-specifier, and we must look it up as a qualified-id in case there is no decl-specifier-seq. For the former lookup, a constructor is (presumably) not an acceptable lookup result, but core issue 147 strongly suggests that the intention was that the lookup should find the constructor anyway for that case.</div>
<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">clang is just failing to apply the rule that this is really a reference to the constructor. In fact, I'm not sure we implement that rule at all.<br>
</blockquote><div><br></div><div>We do: look for err_out_of_line_type_names_constructor. It seems that whoever implemented that interpreted "constructor is an acceptable lookup result" as meaning "appears somewhere a constructor could be declared". We reject this, for instance:</div>
<div><br></div><div>struct S {}; S::S(i);</div></div>