Bugs item #2901705, was opened at 2009-11-21 14:58 Message generated for change (Comment added) made by ivmai You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=865514&aid=2901705&group_id=173455
Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: MinGW32CE (arm-wince-mingw32ce Group: None Status: Open Resolution: Accepted Priority: 5 Private: No Submitted By: Ivan Maidanski (ivmai) Assigned to: Nobody/Anonymous (nobody) Summary: broken winmain_ce.c? Initial Comment: It seems that __mainArgs() in winmain_ce.c produces a bad entry in __argv[] when a single argument is passed to the program. See the test case (which crashes if one arg is passed to it) - to run it on my arm box I've created "a.lnk" file containing: 255#"\SDMMC\Temp\a.exe" x PS. At present, to workaround the bug, I use a third-party WinMain() wrapper for main(). ---------------------------------------------------------------------- >Comment By: Ivan Maidanski (ivmai) Date: 2009-12-10 14:34 Message: Thanks. (I also tried itrating up to argc-1 and it results in SEGV but this is harder to reproduce.) ---------------------------------------------------------------------- Comment By: Pedro Alves (pedroalves) Date: 2009-12-10 14:17 Message: On the other hand, these points: " — argv[argc] shall be a null pointer. — If the value of argc is greater than zero, the array members argv[0] through argv[argc-1] inclusive shall contain pointers to strings, which are given implementation-defined values by the host environment prior to program startup" may mean your test is defined after all. Hmm. I'll take a new look at this then. ---------------------------------------------------------------------- Comment By: Pedro Alves (pedroalves) Date: 2009-12-10 14:13 Message: >> Your test is borked. You should be iterating from 0 to argc. >You just suggest this to workaround the bug, right? No, I'm saying that your test is no C. It is broken. It is doing undefined things. > Or, could you refer to >a standard prohibiting comparing argv[i] against NULL? See the C standard, "5.1.2.2.1 Program startup". You're making up that guarantee. Only argv[0].. argv[argc-1] are defined. "1 The function called at program startup is named main. The implementation declares no prototype for this function. It shall be defined with a return type of int and with no parameters: int main(void) { /* ... */ } or with two parameters (referred to here as argc and argv, though any names may be used, as they are local to the function in which they are declared): int main(int argc, char *argv[]) { /* ... */ } or equivalent;9) or in some other implementation-defined manner. 2 If they are declared, the parameters to the main function shall obey the following constraints: — The value of argc shall be nonnegative. — argv[argc] shall be a null pointer. — If the value of argc is greater than zero, the array members argv[0] through argv[argc-1] inclusive shall contain pointers to strings, which are given implementation-defined values by the host environment prior to program startup. The intent is to supply to the program information determined prior to program startup from elsewhere in the hosted environment. If the host environment is not capable of supplying strings with letters in both uppercase and lowercase, the implementation shall ensure that the strings are received in lowercase. — If the value of argc is greater than zero, the string pointed to by argv[0] represents the program name; argv[0][0] shall be the null character if the program name is not available from the host environment. If the value of argc is greater than one, the strings pointed to by argv[1] through argv[argc-1] represent the program parameters. — The parameters argc and argv and the strings pointed to by the argv array shall be modifiable by the program, and retain their last-stored values between program startup and program termination. " ---------------------------------------------------------------------- Comment By: Ivan Maidanski (ivmai) Date: 2009-12-10 14:01 Message: > Your test is borked. You should be iterating from 0 to argc. You just suggest this to workaround the bug, right? Or, could you refer to a standard prohibiting comparing argv[i] against NULL? ---------------------------------------------------------------------- Comment By: Pedro Alves (pedroalves) Date: 2009-12-10 13:40 Message: Your test is borked. You should be iterating from 0 to argc. - for (i = 0; argv[i]; i++) + for (i = 0; i < argc; i++) printf("%s\n", argv[i]); return 0; ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=865514&aid=2901705&group_id=173455 ------------------------------------------------------------------------------ Return on Information: Google Enterprise Search pays you back Get the facts. http://p.sf.net/sfu/google-dev2dev _______________________________________________ Cegcc-devel mailing list Cegcc-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/cegcc-devel