Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Type coercion into scalar fails with internal compiler error #3973

Closed
sndels opened this issue Sep 27, 2021 · 1 comment · Fixed by #3994
Closed

Type coercion into scalar fails with internal compiler error #3973

sndels opened this issue Sep 27, 2021 · 1 comment · Fixed by #3994

Comments

@sndels
Copy link

sndels commented Sep 27, 2021

Implicit narrowing conversions into a scalar type seem to cause Internal Compiler error: llvm::cast<X>() argument of incompatible type!. Doesn't appear to happen when coercing into a vector type.

Minimal example, reproduces with dndxc.exe from de6a8ed's AppVeyor build
Fails: -enable-templates -DFAILURE_CASE
Compiles: -enable-templates

#ifdef FAILURE_CASE
template<typename T>
T Fn(T input)
{
    T ret = input - 1.f;

    return ret;
}

#else

template<typename T>
T Fn(T input)
{
    T ret = input - (T)1.f;

    return ret;
}

#endif

void main()
{
    Fn(1.0);
}
@llvm-beanz
Copy link
Collaborator

Actually... never mind on that... After PR #3991, this code causes a different error to arise in the compiler. I'll get on that too.

llvm-beanz added a commit to llvm-beanz/DirectXShaderCompiler that referenced this issue Oct 11, 2021
When resolving template argument types if the originating type is a
literal type (i.e. `literal float` or `literal int`), we should instead
substitute the appropriate 32-bit type.

This change is two pieces:

The first translates template arguments from `literal <x>` into the
appropriate 32-bit type after deduction but before generating the
instantiated decl for non-builtin templates.

The second part allows `literal <x>` template parameters to match
against the appropriate instantiated 32-bit types.

This resolves microsoft#3973.
llvm-beanz added a commit that referenced this issue Oct 11, 2021
When resolving template argument types if the originating type is a
literal type (i.e. `literal float` or `literal int`), we should instead
substitute the appropriate 32-bit type.

This change is two pieces:

The first translates template arguments from `literal <x>` into the
appropriate 32-bit type after deduction but before generating the
instantiated decl for non-builtin templates.

The second part allows `literal <x>` template parameters to match
against the appropriate instantiated 32-bit types.

This resolves #3973.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants