D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 21503 - Incorrect C main signature causes undefined behavior in @safe code
Summary: Incorrect C main signature causes undefined behavior in @safe code
Status: RESOLVED DUPLICATE of issue 22831
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: x86_64 Linux
: P1 normal
Assignee: No Owner
URL:
Keywords: safe
Depends on:
Blocks:
 
Reported: 2020-12-26 15:11 UTC by Paul Backus
Modified: 2022-04-13 12:29 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Paul Backus 2020-12-26 15:11:48 UTC
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 Dennis 2022-04-13 12:29:31 UTC
Fixed by https://github.com/dlang/dmd/pull/13749

*** This issue has been marked as a duplicate of issue 22831 ***