Skip to content

ICE in linemap_ordinary_map_lookup, at libcpp/line-map.cc:1197 #4740

Description

@matthiaskrgr

auto-reduced (treereduce-rust):

//@compile-flags: -frust-incomplete-and-experimental-compiler-do-not-use -frust-crate-attr=no_core
trait FromUnchecked {
    fn from_unchecked();
}

impl FromUnchecked
    for [(); match || 1 {
        n => n(),
    }]
{
}

original:

// https://github.com/rust-lang/rust/issues/58212
//@ check-pass

trait FromUnchecked {
    fn from_unchecked();
}

impl FromUnchecked for [(); match || 1 {
        n => n(),
        //~^ ERROR cannot call non-const closure in constants
    }] {
    fn from_unchecked() {
        let mut array: Self = [0; 1];
        let _ptr = &mut array as *mut [u8] as *mut u8;
    }
}

fn main() {
}

Version information:

c539964

Possibly related line of code:

gccrs/libcpp/line-map.cc

Lines 1191 to 1203 in c539964

else
mn = md;
}
set->info_ordinary.m_cache = mn;
const line_map_ordinary *result = LINEMAPS_ORDINARY_MAP_AT (set, mn);
linemap_assert (line >= MAP_START_LOCATION (result));
return result;
}
/* Given a source location yielded by a macro map, returns that map.
Since the set is built chronologically, the logical lines are
monotonic decreasing, and so the list is sorted and we can use a

Command:
/home/matthias/vcs/github/gccrs/gccrs-build/gcc/crab1 -frust-incomplete-and-experimental-compiler-do-not-use -frust-crate-attr=no_core -frust-crate-attr=feature(no_core)

Program output

crab1: internal compiler error: in linemap_ordinary_map_lookup, at libcpp/line-map.cc:1197
0x32edd17 internal_error(char const*, ...)
	../../gcc/diagnostic-global-context.cc:787
0xc847b9 fancy_abort(char const*, int, char const*)
	../../gcc/diagnostics/context.cc:1813
0x3436d22 linemap_ordinary_map_lookup
	../../libcpp/line-map.cc:1197
0x343a97b linemap_lookup(line_maps const*, unsigned long)
	../../libcpp/line-map.cc:1153
0x343a97b linemap_location_in_system_header_p(line_maps const*, unsigned long)
	../../libcpp/line-map.cc:1419
0x1b1f57b in_system_header_at(unsigned long)
	../../gcc/input.h:160
0x1b1f57b set_inlining_locations
	../../gcc/tree-diagnostic.cc:167
0x32f996d diagnostics::context::get_any_inlining_info(diagnostics::diagnostic_info*)
	../../gcc/diagnostics/context.cc:1227
0x32f996d diagnostics::context::diagnostic_enabled(diagnostics::diagnostic_info*)
	../../gcc/diagnostics/context.cc:1254
0x32fbcb5 diagnostics::context::report_diagnostic(diagnostics::diagnostic_info*)
	../../gcc/diagnostics/context.cc:1413
0x32fc5b2 diagnostics::context::diagnostic_impl(rich_location*, diagnostics::metadata const*, diagnostics::option_id, char const*, __va_list_tag (*) [1], diagnostics::kind)
	../../gcc/diagnostics/context.cc:1689
0x32edb92 fatal_error(unsigned long, char const*, ...)
	../../gcc/diagnostic-global-context.cc:766
0xd0b602 rust_be_fatal_error(unsigned long, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)
	../../gcc/rust/rust-diagnostics.cc:329
0xd0b6cd rust_fatal_error(unsigned long, char const*, ...)
	../../gcc/rust/rust-diagnostics.cc:338
0x10e979c Rust::Resolver::TypeCheckExpr::visit(Rust::HIR::ClosureExpr&)
	../../gcc/rust/typecheck/rust-hir-type-check-expr.cc:1978
0x10dd3a0 Rust::Resolver::TypeCheckExpr::Resolve(Rust::HIR::Expr&)
	../../gcc/rust/typecheck/rust-hir-type-check-expr.cc:53
0x10e1ef5 Rust::Resolver::TypeCheckExpr::visit(Rust::HIR::MatchExpr&)
	../../gcc/rust/typecheck/rust-hir-type-check-expr.cc:1820
0x10dd3a0 Rust::Resolver::TypeCheckExpr::Resolve(Rust::HIR::Expr&)
	../../gcc/rust/typecheck/rust-hir-type-check-expr.cc:53
0x10e246a ???
	../../gcc/rust/typecheck/rust-hir-type-check-expr.h:55
0x10dd3a0 Rust::Resolver::TypeCheckExpr::Resolve(Rust::HIR::Expr&)
	../../gcc/rust/typecheck/rust-hir-type-check-expr.cc:53
/home/matthias/vcs/github/gccrs/gccrs-build/gcc/crab1 /tmp/icemaker_global_tempdir.Wibfk44xxT1v/rustc_testrunner_tmpdir_reporting.4wPa6UxYOuBY/mvce.rs -o/tmp/icemaker_global_tempdir.Wibfk44xxT1v/rustc_testrunner_tmpdir_reporting.4wPa6UxYOuBY/binaryname -frust-incomplete-and-experimental-compiler-do-not-use -frust-crate-attr=no_core -frust-crate-attr=feature(no_core)
Please submit a full bug report, with preprocessed source (by using -freport-bug).
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions