On 07/05/2020 17:16, Witold Baryluk wrote: > Package: gdc > Version: 4:9.2.1-3.1 > Severity: normal > > Dear Maintainer, > > According to language spec: > > https://dlang.org/spec/function.html#main > > """ > 19.20 main() Function > > For console programs, main() serves as the entry point. It gets called > after all the module initializers are run, and after any unittests are > run. After it returns, all the module destructors are run. main() must be > declared using one of the following forms: > > void main() { ... } > void main(string[] args) { ... } > int main() { ... } > int main(string[] args) { ... } > """ > > > However: > $ cat dlang.d > void main() { > } > $ gdc -flto dlang.d > /usr/lib/gcc/x86_64-linux-gnu/9/include/d/__entrypoint.di:33:5: warning: type > of ‘_Dmain’ does not match original declaration [-Wlto-type-mismatch] > 33 | int _Dmain(char[][] args); > | ^ > dlang.d:2:6: note: type mismatch in parameter 1 > 2 | void main() { > | ^ > dlang.d:2:6: note: type ‘void’ should match type ‘struct char[][]’ > dlang.d:2:6: note: ‘D main’ was previously declared here > $ > > It does compile fine using `int mine(string[] args)` (and returning 0 > from it) and run correctly. > > Also the message 'void' should match type 'struct char[][]' is confusing. > 'struct'? void (return type?) should match it. Weird wording. I guess, > maybe it is parameter 1, which is not in my definition, but should be > string[]. But I am guessing here. Wording is weird and unclear what is > what. >
Internally the last parameter type is 'void' to denote the end of the list (otherwise it's assumed the function is variadic). Yes, it's a strange message, but this is coming from within the gcc middle-end, and warnings rarely make sense there post lowering. This was fixed in PR d/90136, which is in gdc-10. Iain.