-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Open
Labels
bugObserved behavior contradicts documented or intended behaviorObserved behavior contradicts documented or intended behaviorenhancementSolving this issue will likely involve adding new logic or components to the codebase.Solving this issue will likely involve adding new logic or components to the codebase.
Milestone
Description
Zig Version
0.11.0-dev.2194+626a75bbc
Steps to Reproduce and Observed Behavior
When building a file containing this code...
const std = @import("std");
fn c () void {}
const b = @ptrToInt(&c);
pub fn main () void {
std.debug.print("{}", .{b});
}
... with this parameters...
zig build-exe f.zig
... I get the following error...
f.zig:40:11: error: unable to evaluate comptime expression
const b = @ptrToInt(&c);
^~~~~~~~~~~~~
f.zig:40:21: note: operation is runtime due to this operand
const b = @ptrToInt(&c);
This does not seem right to me, since it is okay to take a function address and print in main. For some reason the compiler is unable to understand a slightly more compilcated arrangement of things. Why is that, I wonder?
Expected Behavior
Should work just fine.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugObserved behavior contradicts documented or intended behaviorObserved behavior contradicts documented or intended behaviorenhancementSolving this issue will likely involve adding new logic or components to the codebase.Solving this issue will likely involve adding new logic or components to the codebase.