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

Preprocessor: Token pasting in function-like macro with no LHS causes crash #77

Closed
ehaas opened this issue Nov 5, 2021 · 1 comment · Fixed by #80
Closed

Preprocessor: Token pasting in function-like macro with no LHS causes crash #77

ehaas opened this issue Nov 5, 2021 · 1 comment · Fixed by #80
Labels
bug Something isn't working

Comments

@ehaas
Copy link
Collaborator

ehaas commented Nov 5, 2021

#define bar(a) ## i
thread 14036537 panic: integer overflow
/Users/ehaas/source/arocc/src/Preprocessor.zig:1253:63: 0x1013ad8e6 in Preprocessor.defineFn (arocc)
                if (pp.token_buf.items[pp.token_buf.items.len - 1].id == .macro_param) {
                                                              ^
/Users/ehaas/source/arocc/src/Preprocessor.zig:1143:53: 0x10137d24b in Preprocessor.define (arocc)
        if (first.id == .l_paren) return pp.defineFn(tokenizer, macro_name, first);
                                                    ^
/Users/ehaas/source/arocc/src/Preprocessor.zig:264:53: 0x101371576 in Preprocessor.preprocess (arocc)
                    .keyword_define => try pp.define(&tokenizer),
                                                    ^
/Users/ehaas/source/arocc/src/main.zig:237:22: 0x1013557a8 in processSource (arocc)
    try pp.preprocess(source);
                     ^
/Users/ehaas/source/arocc/src/main.zig:223:22: 0x10134a161 in handleArgs (arocc)
        processSource(comp, source, builtin, user_macros) catch |e| switch (e) {
                     ^
/Users/ehaas/source/arocc/src/main.zig:41:15: 0x1013472ed in main (arocc)
    handleArgs(&comp, args) catch |err| switch (err) {
              ^
/Users/ehaas/source/zig/build/lib/zig/std/start.zig:524:29: 0x1013c4d7c in std.start.callMain (arocc)
            return root.main();
                            ^
/Users/ehaas/source/zig/build/lib/zig/std/start.zig:469:12: 0x10134b267 in std.start.callMainWithArgs (arocc)
    return @call(.{ .modifier = .always_inline }, callMain, .{});
           ^
/Users/ehaas/source/zig/build/lib/zig/std/start.zig:434:12: 0x10134b1a5 in std.start.main (arocc)
    return @call(.{ .modifier = .always_inline }, callMainWithArgs, .{ @intCast(usize, c_argc), c_argv, envp });
           ^
???:?:?: 0x7fff204ecf3c in ??? (???)
???:?:?: 0x1 in ??? (???)
[1]    19263 abort      ./zig-out/bin/arocc test/cases/tokenpaste.c
@doppioandante
Copy link
Contributor

Should be easy to fix, let me try

@Vexu Vexu added the bug Something isn't working label Nov 5, 2021
doppioandante added a commit to doppioandante/arocc that referenced this issue Nov 6, 2021
@Vexu Vexu closed this as completed in #80 Nov 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants