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

miscompilation conditional in fmt arg #5230

Closed
markfirmware opened this issue Apr 30, 2020 · 2 comments
Closed

miscompilation conditional in fmt arg #5230

markfirmware opened this issue Apr 30, 2020 · 2 comments
Labels
bug Observed behavior contradicts documented or intended behavior miscompilation The compiler reports success but produces semantically incorrect code. stage1 The process of building from source via WebAssembly and the C backend.
Milestone

Comments

@markfirmware
Copy link
Contributor

markfirmware commented Apr 30, 2020

pub fn main() void {
    show(T{});
}

const T = struct {
    b: bool = false,
};

fn show(t: T) void {
    @import("std").debug.warn("{}\n", .{if (t.b) @as(u32, 1) else 0});
}

This should print 0 but instead prints 1.

Related #3882

@Vexu Vexu added bug Observed behavior contradicts documented or intended behavior miscompilation The compiler reports success but produces semantically incorrect code. stage1 The process of building from source via WebAssembly and the C backend. labels Apr 30, 2020
@Vexu Vexu added this to the 0.7.0 milestone Apr 30, 2020
@andrewrk andrewrk modified the milestones: 0.7.0, 0.8.0 Oct 17, 2020
@andrewrk andrewrk modified the milestones: 0.8.0, 0.9.0 Nov 6, 2020
@andrewrk andrewrk modified the milestones: 0.9.0, 0.10.0 May 19, 2021
@lordnoriyuki
Copy link

Even simpler example:

var f = false;
std.log.info("{} {s}", .{ f, if (f) "TRUE " else "FALSE" });

Prints "false TRUE" when it should print "false FALSE"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Observed behavior contradicts documented or intended behavior miscompilation The compiler reports success but produces semantically incorrect code. stage1 The process of building from source via WebAssembly and the C backend.
Projects
None yet
Development

No branches or pull requests

5 participants
@andrewrk @lordnoriyuki @Vexu @markfirmware and others