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

assigning/initializing pointer to member of struct accessed through mutable pointer triggers assertion #130

Open
michael-kenzel opened this issue Sep 4, 2022 · 1 comment

Comments

@michael-kenzel
Copy link
Contributor

the following code will reproduce the issue:

struct Req {}

struct X {
	_: u32,
	req: Req
}

fn test(x: &mut X) {
	let mut p = x;
	let r = &mut p.req;
}

triggers

thorin/src/thorin/primop.cpp:80: thorin::LEA::LEA(const thorin::Def*, const thorin::Def*, thorin::Debug): Assertion `false && "unreachable"' failed.
@stlemme
Copy link
Member

stlemme commented Sep 9, 2022

Modifying the sample to let r = &mut (*p).req; will avoid the assertion.
But this leads to the follow up problem in:

fn test(x: &mut X) {
    let mut p:&mut X = x;
    // let mut r = &mut p.req;
    let mut r = &mut (*p).req;
    // this triggers Assertion failed: (!r || dynamic_cast<L*>(r)) && "cast not possible", file D:\Projects\anydsl\thorin\src\thorin/util/cast.h, line 42
    // r.val = 3;
    // this will properly update req in x
    (*r).val = 3;
}

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