www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - Nested main function should be treated like a common function

reply zwang <nehzgnaw gmail.com> writes:
Nested main function should be treated like a common function.
If void f(){int main(){return 0;}} is acceptable, why isn't
void f(){int main(int){return 0;}} ?

PS. DMD 0.112 displays the following error message:
function test.f.main parameters must be main() or main(char[][] args)
Feb 03 2005
next sibling parent =?ISO-8859-1?Q?Anders_F_Bj=F6rklund?= <afb algonet.se> writes:
zwang wrote:

 Nested main function should be treated like a common function.
 If void f(){int main(){return 0;}} is acceptable, why isn't
 void f(){int main(int){return 0;}} ?
Sounds like a bug in dmd/func.c, int FuncDeclaration::isMain :
 int FuncDeclaration::isMain()
 {
     return ident && strcmp(ident->toChars(), "main") == 0 &&
 	linkage != LINKc && !isMember();
 }
Should probably include a check with !isNested() as well... ? --anders PS. I find this to be more amusing: cdouble main() { return 0 + 0i; }
Feb 03 2005
prev sibling parent reply Thomas Kuehne <thomas-dloop kuehne.thisisspam.cn> writes:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

zwang schrieb am Thu, 03 Feb 2005 22:37:02 +0800:
 Nested main function should be treated like a common function.
 If void f(){int main(){return 0;}} is acceptable, why isn't
 void f(){int main(int){return 0;}} ?

 PS. DMD 0.112 displays the following error message:
 function test.f.main parameters must be main() or main(char[][] args)
Added to DStress as http://dstress.kuehne.cn/run/nested_function_05.d http://dstress.kuehne.cn/run/nested_function_06.d Thomas -----BEGIN PGP SIGNATURE----- iD8DBQFCAj+/3w+/yD4P9tIRAoOsAJ0aPaNv76ROMRpm6dXReqTMXxF4eQCdGJH2 5BxcNBieCCUDxyWBss5LqTI= =Ak6A -----END PGP SIGNATURE-----
Feb 03 2005
parent zwang <nehzgnaw gmail.com> writes:
So fast :)

Thomas Kuehne wrote:
 -----BEGIN PGP SIGNED MESSAGE-----
 Hash: SHA1
 
 zwang schrieb am Thu, 03 Feb 2005 22:37:02 +0800:
 
Nested main function should be treated like a common function.
If void f(){int main(){return 0;}} is acceptable, why isn't
void f(){int main(int){return 0;}} ?

PS. DMD 0.112 displays the following error message:
function test.f.main parameters must be main() or main(char[][] args)
Added to DStress as http://dstress.kuehne.cn/run/nested_function_05.d http://dstress.kuehne.cn/run/nested_function_06.d Thomas -----BEGIN PGP SIGNATURE----- iD8DBQFCAj+/3w+/yD4P9tIRAoOsAJ0aPaNv76ROMRpm6dXReqTMXxF4eQCdGJH2 5BxcNBieCCUDxyWBss5LqTI= =Ak6A -----END PGP SIGNATURE-----
Feb 03 2005