-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Closed
Labels
backend-llvmThe LLVM backend outputs an LLVM IR Module.The LLVM backend outputs an LLVM IR Module.bugObserved behavior contradicts documented or intended behaviorObserved behavior contradicts documented or intended behaviorupstreamAn issue with a third party project that Zig uses.An issue with a third party project that Zig uses.
Milestone
Description
export fn square(num: u8) u8 {
//while(true){} // would generate loop
return eternity(123);
}
pub fn eternity(bla:u8) u8 {
while(true)// is optimized away completely
{}
}
See asm output on goldbold.
As you said during live coding, it seems like the eternal loop is considered to have no side effects and is thus removed.
Expected behaviour would be to refuse compilation
- as there is no return of an u8
- as in case of
eternity
being declared as returningvoid
, an implicitreturn;
at the end of the function cannot be reached
Metadata
Metadata
Assignees
Labels
backend-llvmThe LLVM backend outputs an LLVM IR Module.The LLVM backend outputs an LLVM IR Module.bugObserved behavior contradicts documented or intended behaviorObserved behavior contradicts documented or intended behaviorupstreamAn issue with a third party project that Zig uses.An issue with a third party project that Zig uses.