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

src/test/ui/asm/sym.rs makes incorrect use of #[track_caller] #73911

Closed
anp opened this issue Jul 1, 2020 · 3 comments
Closed

src/test/ui/asm/sym.rs makes incorrect use of #[track_caller] #73911

anp opened this issue Jul 1, 2020 · 3 comments
Labels
C-bug Category: This is a bug.

Comments

@anp
Copy link
Member

anp commented Jul 1, 2020

In this test:

// The compiler will generate a shim to hide the caller location parameter.
#[track_caller]
fn f2() -> i32 {
222
}

I don't see anything in the current RFC text to suggest that the sym usage here should create a call shim, as they're only created when taking function pointers. Is there a function pointer being created in this test that I'm missing?

cc @Amanieu @eddyb

@anp anp added the C-bug Category: This is a bug. label Jul 1, 2020
@Amanieu
Copy link
Member

Amanieu commented Jul 1, 2020

I did it this way because it is the only reasonable way to handle #[track_caller] with asm. The only other alternative would be to disallow the use of #[track_caller] for sym operands.

@eddyb
Copy link
Member

eddyb commented Jul 1, 2020

I think I was too quick to dismiss the implementation - this looks like it does reify: https://godbolt.org/z/AnWrTP.
But I didn't actually see where that happens, I'll have to take another look.

EDIT: ugh, bool args strike again:

visit_fn_use(self.tcx, fn_ty, false, source, &mut self.output);
is_direct_call: bool,

I could've sworn that was is_indirect (maybe it's miri which has that?)

@eddyb eddyb closed this as completed Jul 1, 2020
@eddyb
Copy link
Member

eddyb commented Jul 1, 2020

That said, maybe f2 should return something like the line number? So that if the direct version was called, it would crash/return an incorrect value.

Also, ideally we'd test stuff like this with .stdout files, so we don't have to trust rustc to not optimize out assert_eqs that involve UB, but sadly I don't think those are set up to test runtime output yet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug.
Projects
None yet
Development

No branches or pull requests

3 participants