Bug 21503 – Incorrect C main signature causes undefined behavior in @safe code

Status
RESOLVED
Resolution
DUPLICATE
Severity
normal
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2020-12-26T15:11:48Z
Last change time
2022-04-13T12:29:31Z
Keywords
safe
Assigned to
No Owner
Creator
Paul Backus

Comments

Comment #0 by snarwin+bugzilla — 2020-12-26T15:11:48Z
Example program: --- extern(C) void main(double[] foo) @safe { import std.stdio; writeln(foo); // undefined behavior } --- To avoid this, the compiler should check the signature of a @safe extern(C) main function for conformance to the C standard.
Comment #1 by dkorpel — 2022-04-13T12:29:31Z
Fixed by https://github.com/dlang/dmd/pull/13749 *** This issue has been marked as a duplicate of issue 22831 ***