Skip to content

Lang items are not checked for well-formedness #86247

Description

@FabianWolff

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions