www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 18273] New: Better C: wrong exit code from main()

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

          Issue ID: 18273
           Summary: Better C: wrong exit code from main()
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: markus oberhumer.com

I've stumbled about this while trying Better C from
https://dlang.org/spec/betterc.html


extern(C) void main()
{
    import core.stdc.stdio : printf;
    printf("Hello betterC\n");
    // BUG: the exit code of this program is wrong (usually not 0)
}


Possible solutions:

  1) the compiler should add an implicit "return 0" for "void main()"; or

  2) require that main() returns "int" in extern C/C++ mode

--
Jan 20 2018