Skip to content

LLVM assertion with extern fn in struct #4360

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

Closed
veddan opened this issue Jan 5, 2013 · 2 comments
Closed

LLVM assertion with extern fn in struct #4360

veddan opened this issue Jan 5, 2013 · 2 comments
Labels
A-codegen Area: Code generation I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
Milestone

Comments

@veddan
Copy link
Contributor

veddan commented Jan 5, 2013

extern fn plusone(u: u8) -> u8 {
    return u + 1;
}

struct S {
    fun: *u8
}

const s: S = S { fun: plusone };

This code does not give any compile errors from rustc, but triggers an assertion in LLVM: "Initializer for struct element doesn't match struct element type!".

Full error message:

rustc: .../rust/src/llvm/lib/VMCore/Constants.cpp:812: llvm::ConstantStruct::ConstantStruct(llvm::StructType*, llvm::ArrayRef<llvm::Constant*>): Assertion `(T->isOpaque() || V[i]->getType() == T->getElementType(i)) && "Initializer for struct element doesn't match struct element type!"' failed.```
@veddan
Copy link
Contributor Author

veddan commented Feb 8, 2013

This issue no longer seems to occur on incoming.

@jdm
Copy link
Contributor

jdm commented Feb 8, 2013

Fixed by 039bfed.

@jdm jdm closed this as completed Feb 8, 2013
RalfJung added a commit to RalfJung/rust that referenced this issue Jun 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-codegen Area: Code generation I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
Projects
None yet
Development

No branches or pull requests

2 participants