[LLVMbugs] [Bug 13769] New: ext_vector_type casts and implicit type conversions are bitwise casts!

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Wed Sep 5 02:00:40 PDT 2012


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

             Bug #: 13769
           Summary: ext_vector_type casts and implicit type conversions
                    are bitwise casts!
           Product: clang
           Version: 3.1
          Platform: PC
        OS/Version: Windows NT
            Status: NEW
          Severity: normal
          Priority: P
         Component: Frontend
        AssignedTo: unassignedclangbugs at nondot.org
        ReportedBy: antonilator at gmail.com
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified


Casts and conversions between ext_vector_types seem to be very surprising
bitwise casts rather than type conversions as I'd except from the behaviour of
C style casts on floats and ints.  Please can this be a type conversion
instead?

E.g. implicit bitwise cast from int to float:

typedef float float4 __attribute__((ext_vector_type(4))); 
typedef int int4 __attribute__((ext_vector_type(4))); 
float4 f(float4 a, int4 b) 
{ 
    return a + b; 
} 
int main(int argc, char **argv)
{
        float4 ff = f((float4){1,2,3,4},(int4){1,2,3,4});
        printf("%f %f %f %f\n",ff.x,ff.y,ff.z,ff.w);
}
gives 1.000000 2.000000 3.000000 4.000000

-fno-lax-vector-conversions helpfully reports the implicit cast as an error,
however fixing that error with an explicit cast still gives a bitwise cast:

float4 f(float4 a, int4 b) {     return a + (float4)b; }

So this behaviour seems very error prone and counterintuitive, please can this
explicit C style cast be a type conversion instead?

If it helps this appears to be coded in Sema::CheckExtVectorCast in
SemaExpr.cpp 
around line 4435 :  Kind = CK_BitCast; (!)

Cheers,

Anton

-- 
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