[LLVMbugs] [Bug 7070] New: Scalar cast to vector, implicit conversion, and function selection

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Thu May 6 08:18:53 PDT 2010


http://llvm.org/bugs/show_bug.cgi?id=7070

           Summary: Scalar cast to vector, implicit conversion, and
                    function selection
           Product: new-bugs
           Version: trunk
          Platform: PC
        OS/Version: Windows XP
            Status: NEW
          Severity: normal
          Priority: P
         Component: new bugs
        AssignedTo: unassignedbugs at nondot.org
        ReportedBy: John.Thompson.JTSoftware at gmail.com
                CC: llvmbugs at cs.uiuc.edu


I think the following three issues are all related.

Scalars cast to vectors should not be allowed
(http://www.freescale.com/files/32bit/doc/ref_manual/ALTIVECPIM.pdf 2.4.6):

float f = 1.0f;
__attribute__((vector_size(16))) float v = (__attribute__((vector_size(16)))
float)f;

clang -cc1 vcast.cpp
(no error generated)

Problem with function selection:

class test
{
public:
    test( float x );
    test(__attribute__((vector_size(16))) float v );
};

int vi = 0;

void func()
{
    test object(vi);
}

>clang -cc1 scalar.cpp
scalar.cpp:13:7: error: call to constructor of 'test' is ambiguous
        test object(vi);
             ^      ~~
scalar.cpp:5:2: note: candidate constructor
        test( float x );
        ^
scalar.cpp:6:2: note: candidate constructor
        test(__attribute__((vector_size(16))) float v );
        ^
scalar.cpp:2:7: note: candidate is the implicit copy constructor
class test
      ^
1 error generated.

Because casts of scalars to vectors should not be allowed, there should really
only be one candidate function.  Adding "explicit" to the vector constructor
doesn't help either.

This is probably the same issue, but just in case:

class SimdReal
{
 public:
    SimdReal(const __attribute__((vector_size(16))) float x);
    SimdReal(float x);
};
class Vector4
{
 public:
    Vector4(const __attribute__((vector_size(16))) float q);
};

void mul(const SimdReal& r);
void mul(const Vector4& v);

float vf = 0.0f;

void func()
{
    mul(vf);
}

>clang -cc1 consel.cpp
consel.cpp:20:2: error: call to 'mul' is ambiguous
        mul(vf);
        ^~~
consel.cpp:13:6: note: candidate function
void mul(const SimdReal& r);
     ^
consel.cpp:14:6: note: candidate function
void mul(const Vector4& v);
     ^
1 error generated.

-- 
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.



More information about the llvm-bugs mailing list