<div>Note that in the actual code, the vector constructor is explicit:</div>
<div> </div>
<div>class test<br>{<br>public:<br> test( float x );<br> explicit test(__attribute__((vector_size(16))) float v );<br>};<br></div>
<div>Shouldn't that help the compiler decide that it's not a candidate?  (gcc doesn't seem to care either way.)</div>
<div> </div>
<div>I have one class like this that is used frequently.  I added a constructor taking an int, but that caused other problems.  Adding a (float) cast to the argument in the instanciations is the hack that seems to work.</div>

<div> </div>
<div>Also, because you can't cast scalars to vectors, I think the implicit conversion code should exclude the vector case.  If you agree, I'll file a bug.<br></div>
<div class="gmail_quote">On Fri, Apr 30, 2010 at 5:44 PM, Eli Friedman <span dir="ltr"><<a href="mailto:eli.friedman@gmail.com">eli.friedman@gmail.com</a>></span> wrote:<br>
<blockquote style="BORDER-LEFT: #ccc 1px solid; MARGIN: 0px 0px 0px 0.8ex; PADDING-LEFT: 1ex" class="gmail_quote">
<div>
<div></div>
<div class="h5">On Fri, Apr 30, 2010 at 5:11 PM, Douglas Gregor <<a href="mailto:dgregor@apple.com">dgregor@apple.com</a>> wrote:<br>><br>> On Apr 30, 2010, at 4:55 PM, John Thompson wrote:<br>><br>>> This doesn't compile.  Should it?:<br>
>><br>>> class test<br>>> {<br>>> public:<br>>>  test( float x );<br>>>  test(__attribute__((vector_size(16))) float v );<br>>> };<br>>> int vi = 0;<br>>> void func()<br>
>> {<br>>>  test object = test(vi);<br>>> }<br>>> C:\Sony\Clang\exp>clang -cc1 scalar.cpp<br>>> scalar.cpp:13:16: error: functional-style cast from 'int' to 'test' is not allowed<br>
>>         test object = test(vi);<br>>>                       ^~~~<br>><br>> The logic for computing implicit conversion sequences in C++ does not know anything about vectors. What you're seeing here is a poor diagnostic due to the cast. Change it to a direct initialization and you'll see the ambiguity:<br>
><br>> t2.cpp:10:7: error: call to constructor of 'test' is ambiguous<br>>  test object(vi);<br>>      ^      ~~<br>> t2.cpp:4:2: note: candidate constructor<br>>  test( float x );<br>>  ^<br>
> t2.cpp:5:2: note: candidate constructor<br>>  test(__attribute__((vector_size(16))) float v );<br>>  ^<br>> t2.cpp:1:7: note: candidate is the implicit copy constructor<br>> class test<br>>      ^<br>><br>
> Clang can't figure out which constructor is the better match.<br><br></div></div>Right, it's treating it like a class which has constructors for, for<br>example, float and double. It does this because our routines for<br>
identifying types do strange things for queries like<br>isRealFloatingType().  See also<br><a href="http://llvm.org/bugs/show_bug.cgi?id=4208" target="_blank">http://llvm.org/bugs/show_bug.cgi?id=4208</a> .<br><font color="#888888"><br>
-Eli<br></font></blockquote></div><br><br clear="all"><br>-- <br>John Thompson<br><a href="mailto:John.Thompson.JTSoftware@gmail.com">John.Thompson.JTSoftware@gmail.com</a><br><br>