Skip to content

ext_vector_type is not compatible with constexpr #20531

@llvmbot

Description

@llvmbot
Bugzilla Link 20157
Version trunk
OS All
Blocks #30794
Reporter LLVM Bugzilla Contributor
CC @hfinkel,@RKSimon,@zygoloid
Fixed by commit(s) b30c166

Extended Description

It seems many uses of a type based on ext_vector_type are not suitable for use in a constexpr, for example:

typedef float attribute((ext_vector_type(4))) float4;

constexpr float4 MultiplyByTwo(float4 x)
{
return x * 2.0f;
}

main.cpp:3:18: error: constexpr function never produces a constant expression [-Winvalid-constexpr]

constexpr float4 MultiplyByTwo(float4 x)
^
main.cpp:5:12: note: subexpression not valid in a constant expression

return x * 2.0f;
^
1 error generated.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugzillaIssues migrated from bugzillaclang:frontendLanguage frontend issues, e.g. anything involving "Sema"

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions