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

Lang items are not checked for well-formedness #86247

Closed
FabianWolff opened this issue Jun 12, 2021 · 2 comments
Closed

Lang items are not checked for well-formedness #86247

FabianWolff opened this issue Jun 12, 2021 · 2 comments

Comments

@FabianWolff
Copy link
Contributor

For instance, one can write:

#![feature(no_core)]
#![no_core]
#![feature(lang_items)]

#[lang = "sized"]
trait Sized {}

#[lang = "start"]
fn start() {}

fn main() {}

which leads to:

Incorrect number of arguments passed to called function!
  call void @_ZN10playground5start17h74a17c08fe33779bE(i8** bitcast (void ()* @_ZN10playground4main17ha7cb2a96f9beaebbE to i8**), i64 %4, i8** %1)
SExt only operates on integer
  %5 = sext void <badref> to i32
in function main
LLVM ERROR: Broken function found, compilation aborted!
error: could not compile `playground`

This can also cause ICEs (such as #83471, whose specific cause I have addressed in #86246 without solving the general problem), and it allows for all kinds of nonsensical lang items to be defined.

@jonas-schievink
Copy link
Contributor

duplicate of #9307

@FabianWolff
Copy link
Contributor Author

duplicate of #9307

Thanks! I did search for existing issues, which turned up mostly ICEs, but apparently I did not go back far enough.

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

No branches or pull requests

2 participants