You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The compiler written in C correctly refuses to compile this:
compiler error in file "asd.jou", line 1: function 'main' must return a value, because it is defined with '-> int'
But the self-hosted compiler compiles this with no warnings, and produces and executable that invokes UB.
In general, the self-hosted compiler has no warnings for using undefined values (return value, variable, anything else). For example, the following program prints an undefined value. The compiler written in C shows a warning about it, but the self-hosted compiler Jou does not.
To fix this properly, the compiler should know whether a value is properly defined, undefined, or maybe undefined depending on e.g. user input. And to do that, we need to analyze Control Flow Graphs (CFGs).
The problem is that the self-hosted compiler doesn't have the simplify_cfg compilation step of the compiler written in C. I omitted simplify_cfg in #562.
The text was updated successfully, but these errors were encountered:
Akuli
changed the title
Warning/error if you forget to return a value
Undefined value warnings/errors
Jan 8, 2025
The following program shouldn't compile:
The compiler written in C correctly refuses to compile this:
But the self-hosted compiler compiles this with no warnings, and produces and executable that invokes UB.
In general, the self-hosted compiler has no warnings for using undefined values (return value, variable, anything else). For example, the following program prints an undefined value. The compiler written in C shows a warning about it, but the self-hosted compiler Jou does not.
To fix this properly, the compiler should know whether a value is properly defined, undefined, or maybe undefined depending on e.g. user input. And to do that, we need to analyze Control Flow Graphs (CFGs).
The problem is that the self-hosted compiler doesn't have the
simplify_cfg
compilation step of the compiler written in C. I omittedsimplify_cfg
in #562.The text was updated successfully, but these errors were encountered: