Skip to content

ICE on &*"string" #30386

Closed
Closed
@jld

Description

@jld

STR:

fn main() {
  let _ = &*"string";
}

Result:

@ref2649 = internal unnamed_addr constant %str_slice { i8* getelementptr inbounds ([6 x i8], [6 x i8]* @str2648, i32 0, i32 0), i64 6 }, align 8
{ i8*, i8* } undef
error: internal compiler error: const expr(10: &*"string") of type &'static str has size 8 instead of 16

This is from trans/consts.rs around line 462. I did some poking around in gdb; for "string" and *"string" the value of llconst is the pointer/len tuple, but for &*"string" it's a pointer to that tuple (seen above), which is wrong.

The value of opt_adj is always None (assuming the breakpoints and debug info are working as expected), which… it's been a long time since I looked at anything in this area, but I vaguely remember adjustments as being about this kind of situation, and it particular it looks like AdjustDerefRef ought to be relevant?

Metadata

Metadata

Assignees

No one assigned

    Labels

    I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions