This is the mail archive of the
glibc-bugs@sourceware.org
mailing list for the glibc project.
[Bug libc/13080] clock() is unusable on 32-bit targets due to wrong type for clock_t
- From: "bugdal at aerifal dot cx" <sourceware-bugzilla at sourceware dot org>
- To: glibc-bugs at sourceware dot org
- Date: Wed, 01 May 2013 22:01:59 +0000
- Subject: [Bug libc/13080] clock() is unusable on 32-bit targets due to wrong type for clock_t
- Auto-submitted: auto-generated
- References: <bug-13080-131 at http dot sourceware dot org/bugzilla/>
http://sourceware.org/bugzilla/show_bug.cgi?id=13080
Rich Felker <bugdal at aerifal dot cx> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|RESOLVED |REOPENED
Resolution|WONTFIX |
--- Comment #6 from Rich Felker <bugdal at aerifal dot cx> 2013-05-01 22:01:59 UTC ---
C99 specified for the clock() function:
"If the processor time used is not available or its value cannot be
represented, the function returns the value (clock_t)(-1).275)
Footnotes
275) In order to measure the time spent in a program, the clock function should
be called at the start of the program and its return value subtracted from the
value returned by subsequent calls."
I read the footnote as implying that, except in the case where (clock_t)-1 has
been returned, programs can rely on well-defined behavior if they subtract the
return values of two different invocations of clock(). Moreover, I believe
returning a negative value other than (clock_t)-1 (which will only be negative
if clock_t is a signed type) is non-conforming. If clock_t is to remain signed,
then the clock() function should detect overflow and return -1 once overflow
has occurred. Since CLOCKS_PER_SEC is required by SUS to be 1000000, overflow
will occur very quickly on 32-bit systems, making the clock() function
essentially useless...
--
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.