Date: Sun, 17 Jan 2021 15:31:46 -0800 From: Mark Millard <marklmi@yahoo.com> To: Walter von Entferndt <walter.von.entferndt@posteo.net> Cc: freebsd-hackers@freebsd.org Subject: Re: Implicit assumptions (was: Re: Some fun with -O2) Message-ID: <FCCDA898-D10A-4770-890A-8809347C7DB3@yahoo.com> In-Reply-To: <22093525.sr7ieKrsik@t450s.local.lan> References: <mailman.29.1610625600.45116.freebsd-hackers@freebsd.org> <1648904.MsCH1bHPGx@t450s.local.lan> <ABC6559D-66E6-4671-A11A-FA225B55C9B6@yahoo.com> <22093525.sr7ieKrsik@t450s.local.lan>
next in thread | previous in thread | raw e-mail | index | archive | help
On 2021-Jan-17, at 13:25, Walter von Entferndt = <walter.von.entferndt@posteo.net> wrote: > . . . > - for (j =3D 1; 0 < j; j *=3D 2) > + /* NOTE This does not reach very large values > time_t_max/2 > + neither the (susceptible for overflow) version > + for (j =3D 1; 0 < j; j *=3D 2) does */ > + for (i =3D j =3D 1; i < PRECISION(INT_MAX); i++, j *=3D 2) I'm unclear on why INT_MAX here. 32767 <=3D INT_MAX for C (and the LP32 data model), but 2147483647 =3D=3D INT_MAX is common (IPL32, LLP64, LP64). The bigtime_test(j) call has j being 2**(i-1), inventing notation for an exponent. So for the 2 identified cases varying the exponent calls for: 2**(1-1) to 2**(14-1) for 0x7FFF=3D=3DINT_MAX 2**(1-1) to 2**(30-1) for 0x7FFFFFFF=3D=3DINT_MAX > bigtime_test (j); and so for the below bigtime_test(j-1): (2**(15-1))-1 for 0x7FFF=3D=3DINT_MAX (2**(31-1))-1 for 0x7FFFFFFF=3D=3DINT_MAX > bigtime_test (j - 1); The above notes are independent of time_t. I'm also unsure of your intended relationship to time_t in general (if any). For example, for time_t being 64 bits (63 value bits) on powerpc (32-bit and 64-bit) for FreeBSD but 32-bit (31 value bits) for i386 for FreeBSD and 64-bit (63 value bits) for amd64 for FreeBSD. (As I understand, FreeBSD does not claim to support INT_MAX<2147483647 even though C of itself does. FreeBSD is just an example here.) It leaves me to wonder about using something that invovled PRECISION(time_t_max). (Not that I've thought that through enough to claim just what would always be appropriate.) > } > irix_6_4_bug (); > spring_forward_gap (); > - exit (0); > + exit (EXIT_SUCCESS); > } > +/*! vi: set ai tabstop=3D8 shiftwidth=3D2: */ Again, I do not make a claim of having thought every aspect of the code through. The above is just what stood out on a quick read. =3D=3D=3D Mark Millard marklmi at yahoo.com ( dsl-only.net went away in early 2018-Mar)
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?FCCDA898-D10A-4770-890A-8809347C7DB3>