Skip to content

bug: anonymous nested tuples #6043

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

Closed
cristobal-montecino opened this issue Aug 13, 2020 · 2 comments
Closed

bug: anonymous nested tuples #6043

cristobal-montecino opened this issue Aug 13, 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

@cristobal-montecino
Copy link

const std = @import("std");

fn print(args: anytype) void {
    std.debug.print("{}\n", .{args});
}
fn three(a0: u64, a1: u64, a2: u64) void {
    print(.{.{a0, a1, a2}});
}

pub fn main() !void {
    three(1,2,3);
}
Segmentation fault at address 0x202740
/home/ce/example.zig:7:15: 0x236f28 in three (output.s)
/home/ce/example.zig:11:10: 0x22fd0b in main (output.s)

Try this code

const std = @import("std");

fn print(args: anytype) void {
    std.debug.print("{}\n", .{args});
}
fn three(a0: u64, a1: u64, a2: u64) void {
    const args = .{a0, a1, a2};
    print(.{args});
}

pub fn main() !void {
    three(1,2,3);
}
struct:8:12{ .0 = struct:7:19{ .0 = 1, .1 = 2, .2 = 3 } }

Try this code

@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 Aug 13, 2020
@Vexu Vexu added this to the 0.7.0 milestone Aug 13, 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
@edt-xx
Copy link

edt-xx commented Jun 15, 2021

A data point. The following code fragment will seg fault. Changing the tuples with .{xxx} to .{"xxx"} and .{aaa} to .{"aaa"} works and the tuples are usable. Looks like it might be something that occurs when the nested tuples have runtime values.

fn gen() void {}
fn exactdiv() void {}
fn fanin() void {}
fn console() void {}

pub fn main() void {
    
var aaa:usize = 150;
var xxx:usize = 5;
    
const pipe =.{ 
    .{     gen, .{aaa} }, 
    .{"a", exactdiv, .{xxx} }, 
    .{"b", fanin}, 
    .{     console,   true}, 
    .{"a"},
    .{ exactdiv, .{7} }, 
    .{"b",              true} 
};

}

@andrewrk andrewrk modified the milestones: 0.14.0, 0.11.0 Jul 22, 2023
@andrewrk
Copy link
Member

Fixed by deleting the stage1 codebase.

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

4 participants