[Issue 21503] New: Incorrect C main signature causes undefined behavior in @safe code

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sat Dec 26 15:11:48 UTC 2020


https://issues.dlang.org/show_bug.cgi?id=21503

          Issue ID: 21503
           Summary: Incorrect C main signature causes undefined behavior
                    in @safe code
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody at puremagic.com
          Reporter: snarwin+bugzilla at gmail.com

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.

--


More information about the Digitalmars-d-bugs mailing list