From: SourceForge.net <no...@so...> - 2004-02-18 02:02:50
|
Bugs item #899213, was opened at 2004-02-18 13:01 Message generated for change (Comment added) made by dannysmith You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=102435&aid=899213&group_id=2435 Category: mingw runtime Group: None >Status: Closed >Resolution: Rejected Priority: 5 Submitted By: Darrin Forelle (darrinf) Assigned to: Danny Smith (dannysmith) Summary: strtoul Initial Comment: 1.c: #include <stdio.h> #include <stdlib.h> #include <errno.h> //include: stdio.h, stdlib.h, errno.h int main(int argc, char *argv[]){ unsigned long number = strtoul(argv[1], 0, 10); if (errno) { perror("Incorrect integer value"); return 1; } printf("number = %lu\n", number); return 0; } gcc 1.c -o 1.exe & 1 abc number = 0 Function strtoul doesn't set errno if the conversion can not be performed. Tested with gcc v3.3.1 (mingw special 20030804-1). ---------------------------------------------------------------------- >Comment By: Danny Smith (dannysmith) Date: 2004-02-18 14:57 Message: Logged In: YES user_id=11494 Luke is correct. Also this is as per ISO standard. Danny ---------------------------------------------------------------------- Comment By: Darrin Forelle (darrinf) Date: 2004-02-18 14:55 Message: Logged In: YES user_id=760771 I'm sorry for the false report. This is an erratum in my C book. According to the C standard the behaviour is correct. ---------------------------------------------------------------------- Comment By: Luke Dunstan (infidel) Date: 2004-02-18 14:33 Message: Logged In: YES user_id=30442 According to the MSDN documentation this is how it is supposed to work. It says that errno is set only if an underflow or overflow occurs, and in a real program you can use endptr (arg 2) to distinguish between an invalid number and a valid zero value. ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=102435&aid=899213&group_id=2435 |