Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c++ > #89514 > unrolled thread
| Started by | Lynn McGuire <lynnmcguire5@gmail.com> |
|---|---|
| First post | 2023-03-07 15:38 -0600 |
| Last post | 2023-04-06 00:42 -0700 |
| Articles | 20 on this page of 146 — 22 participants |
Back to article view | Back to comp.lang.c++
"C++ on the Move" by Darryl K. Taft Lynn McGuire <lynnmcguire5@gmail.com> - 2023-03-07 15:38 -0600
Re: "C++ on the Move" by Darryl K. Taft legalize+jeeves@mail.xmission.com (Richard) - 2023-03-07 22:08 +0000
Re: "C++ on the Move" by Darryl K. Taft Lynn McGuire <lynnmcguire5@gmail.com> - 2023-03-07 16:25 -0600
Re: "C++ on the Move" by Darryl K. Taft legalize+jeeves@mail.xmission.com (Richard) - 2023-03-07 23:10 +0000
Re: "C++ on the Move" by Darryl K. Taft Paavo Helde <eesnimi@osa.pri.ee> - 2023-03-08 08:40 +0200
Re: "C++ on the Move" by Darryl K. Taft Lynn McGuire <lynnmcguire5@gmail.com> - 2023-04-05 19:30 -0500
Re: "C++ on the Move" by Darryl K. Taft Öö Tiib <ootiib@hot.ee> - 2023-03-07 23:21 -0800
Re: "C++ on the Move" by Darryl K. Taft scott@slp53.sl.home (Scott Lurndal) - 2023-03-08 16:10 +0000
Re: "C++ on the Move" by Darryl K. Taft David Brown <david.brown@hesbynett.no> - 2023-03-08 19:47 +0100
Re: "C++ on the Move" by Darryl K. Taft Michael S <already5chosen@yahoo.com> - 2023-03-08 11:21 -0800
Re: "C++ on the Move" by Darryl K. Taft scott@slp53.sl.home (Scott Lurndal) - 2023-03-08 19:49 +0000
Re: "C++ on the Move" by Darryl K. Taft Michael S <already5chosen@yahoo.com> - 2023-03-08 12:08 -0800
Re: "C++ on the Move" by Darryl K. Taft Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2023-03-08 09:52 -0800
Re: "C++ on the Move" by Darryl K. Taft Malcolm McLean <malcolm.arthur.mclean@gmail.com> - 2023-03-08 10:18 -0800
Re: "C++ on the Move" by Darryl K. Taft David Brown <david.brown@hesbynett.no> - 2023-03-08 20:45 +0100
Re: "C++ on the Move" by Darryl K. Taft "Alf P. Steinbach" <alf.p.steinbach@gmail.com> - 2023-03-08 19:20 +0100
Re: "C++ on the Move" by Darryl K. Taft James Kuyper <jameskuyper@alumni.caltech.edu> - 2023-03-08 14:10 -0500
Re: "C++ on the Move" by Darryl K. Taft "Alf P. Steinbach" <alf.p.steinbach@gmail.com> - 2023-03-08 22:34 +0100
Re: "C++ on the Move" by Darryl K. Taft Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2023-03-08 14:29 -0800
Re: "C++ on the Move" by Darryl K. Taft David Brown <david.brown@hesbynett.no> - 2023-03-09 00:59 +0100
Re: "C++ on the Move" by Darryl K. Taft James Kuyper <jameskuyper@alumni.caltech.edu> - 2023-03-08 18:11 -0500
Re: "C++ on the Move" by Darryl K. Taft Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2023-03-08 12:28 -0800
Re: "C++ on the Move" by Darryl K. Taft Michael S <already5chosen@yahoo.com> - 2023-03-08 12:48 -0800
Re: "C++ on the Move" by Darryl K. Taft "Alf P. Steinbach" <alf.p.steinbach@gmail.com> - 2023-03-08 22:40 +0100
Re: "C++ on the Move" by Darryl K. Taft David Brown <david.brown@hesbynett.no> - 2023-03-09 01:12 +0100
Re: "C++ on the Move" by Darryl K. Taft Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2023-03-08 16:27 -0800
Re: "C++ on the Move" by Darryl K. Taft David Brown <david.brown@hesbynett.no> - 2023-03-09 13:52 +0100
Re: "C++ on the Move" by Darryl K. Taft Michael S <already5chosen@yahoo.com> - 2023-03-09 12:47 -0800
Re: "C++ on the Move" by Darryl K. Taft David Brown <david.brown@hesbynett.no> - 2023-03-09 01:08 +0100
Re: "C++ on the Move" by Darryl K. Taft Malcolm McLean <malcolm.arthur.mclean@gmail.com> - 2023-03-09 02:08 -0800
Re: "C++ on the Move" by Darryl K. Taft David Brown <david.brown@hesbynett.no> - 2023-03-09 14:06 +0100
Re: "C++ on the Move" by Darryl K. Taft Malcolm McLean <malcolm.arthur.mclean@gmail.com> - 2023-03-09 07:14 -0800
Re: "C++ on the Move" by Darryl K. Taft David Brown <david.brown@hesbynett.no> - 2023-03-09 20:32 +0100
Re: "C++ on the Move" by Darryl K. Taft Michael S <already5chosen@yahoo.com> - 2023-03-09 12:42 -0800
Re: "C++ on the Move" by Darryl K. Taft David Brown <david.brown@hesbynett.no> - 2023-03-10 00:30 +0100
Re: "C++ on the Move" by Darryl K. Taft scott@slp53.sl.home (Scott Lurndal) - 2023-03-10 15:01 +0000
Re: "C++ on the Move" by Darryl K. Taft David Brown <david.brown@hesbynett.no> - 2023-03-10 16:38 +0100
Re: "C++ on the Move" by Darryl K. Taft scott@slp53.sl.home (Scott Lurndal) - 2023-03-10 16:36 +0000
Re: "C++ on the Move" by Darryl K. Taft David Brown <david.brown@hesbynett.no> - 2023-03-11 10:43 +0100
Re: "C++ on the Move" by Darryl K. Taft Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2023-03-08 12:59 -0800
Re: "C++ on the Move" by Darryl K. Taft Öö Tiib <ootiib@hot.ee> - 2023-03-09 03:03 -0800
Re: "C++ on the Move" by Darryl K. Taft Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2023-03-09 12:12 -0800
Re: "C++ on the Move" by Darryl K. Taft Öö Tiib <ootiib@hot.ee> - 2023-03-09 19:20 -0800
Re: "C++ on the Move" by Darryl K. Taft David Brown <david.brown@hesbynett.no> - 2023-03-10 10:36 +0100
Re: "C++ on the Move" by Darryl K. Taft Öö Tiib <ootiib@hot.ee> - 2023-03-10 04:27 -0800
Re: "C++ on the Move" by Darryl K. Taft Malcolm McLean <malcolm.arthur.mclean@gmail.com> - 2023-03-10 05:13 -0800
Re: "C++ on the Move" by Darryl K. Taft Öö Tiib <ootiib@hot.ee> - 2023-03-10 06:05 -0800
Re: "C++ on the Move" by Darryl K. Taft David Brown <david.brown@hesbynett.no> - 2023-03-10 15:59 +0100
Re: "C++ on the Move" by Darryl K. Taft kalevi@kolttonen.fi (Kalevi Kolttonen) - 2023-03-10 15:14 +0000
Re: "C++ on the Move" by Darryl K. Taft David Brown <david.brown@hesbynett.no> - 2023-03-10 16:45 +0100
Re: "C++ on the Move" by Darryl K. Taft kalevi@kolttonen.fi (Kalevi Kolttonen) - 2023-03-10 16:02 +0000
Re: "C++ on the Move" by Darryl K. Taft David Brown <david.brown@hesbynett.no> - 2023-03-13 11:45 +0100
Re: "C++ on the Move" by Darryl K. Taft Muttley@dastardlyhq.com - 2023-03-13 12:00 +0000
Re: "C++ on the Move" by Darryl K. Taft kalevi@kolttonen.fi (Kalevi Kolttonen) - 2023-03-13 12:26 +0000
Re: "C++ on the Move" by Darryl K. Taft Muttley@dastardlyhq.com - 2023-03-13 15:00 +0000
Re: "C++ on the Move" by Darryl K. Taft kalevi@kolttonen.fi (Kalevi Kolttonen) - 2023-03-13 15:18 +0000
Re: "C++ on the Move" by Darryl K. Taft Muttley@dastardlyhq.com - 2023-03-13 16:00 +0000
Re: "C++ on the Move" by Darryl K. Taft kalevi@kolttonen.fi (Kalevi Kolttonen) - 2023-03-13 18:43 +0000
Re: "C++ on the Move" by Darryl K. Taft Muttley@dastardlyhq.com - 2023-03-14 09:26 +0000
Re: "C++ on the Move" by Darryl K. Taft David Brown <david.brown@hesbynett.no> - 2023-03-14 13:30 +0100
Re: "C++ on the Move" by Darryl K. Taft Muttley@dastardlyhq.com - 2023-03-14 16:16 +0000
Re: "C++ on the Move" by Darryl K. Taft David Brown <david.brown@hesbynett.no> - 2023-03-14 17:49 +0100
Re: "C++ on the Move" by Darryl K. Taft Muttley@dastardlyhq.com - 2023-03-14 17:14 +0000
Re: "C++ on the Move" by Darryl K. Taft David Brown <david.brown@hesbynett.no> - 2023-03-14 23:05 +0100
Re: "C++ on the Move" by Darryl K. Taft Muttley@dastardlyhq.com - 2023-03-15 08:39 +0000
Re: "C++ on the Move" by Darryl K. Taft David Brown <david.brown@hesbynett.no> - 2023-03-15 17:31 +0100
Re: "C++ on the Move" by Darryl K. Taft Muttley@dastardlyhq.com - 2023-03-15 17:11 +0000
Re: "C++ on the Move" by Darryl K. Taft Ben Bacarisse <ben.lists@bsb.me.uk> - 2023-03-15 00:10 +0000
Re: "C++ on the Move" by Darryl K. Taft Tim Rentsch <tr.17687@z991.linuxsc.com> - 2023-03-14 14:52 -0700
Re: "C++ on the Move" by Darryl K. Taft David Brown <david.brown@hesbynett.no> - 2023-03-13 20:17 +0100
Re: "C++ on the Move" by Darryl K. Taft kalevi@kolttonen.fi (Kalevi Kolttonen) - 2023-03-13 19:31 +0000
Re: "C++ on the Move" by Darryl K. Taft Paavo Helde <eesnimi@osa.pri.ee> - 2023-03-14 00:01 +0200
Re: "C++ on the Move" by Darryl K. Taft gst <g.starck@gmail.com> - 2023-03-13 23:49 -0700
Re: "C++ on the Move" by Darryl K. Taft "Alf P. Steinbach" <alf.p.steinbach@gmail.com> - 2023-03-14 11:04 +0100
Re: "C++ on the Move" by Darryl K. Taft gst <g.starck@gmail.com> - 2023-03-14 03:26 -0700
Re: "C++ on the Move" by Darryl K. Taft David Brown <david.brown@hesbynett.no> - 2023-03-14 09:08 +0100
Re: "C++ on the Move" by Darryl K. Taft Tim Rentsch <tr.17687@z991.linuxsc.com> - 2023-03-14 01:21 -0700
Re: "C++ on the Move" by Darryl K. Taft Tim Rentsch <tr.17687@z991.linuxsc.com> - 2023-03-14 15:12 -0700
Re: "C++ on the Move" by Darryl K. Taft Muttley@dastardlyhq.com - 2023-03-14 09:31 +0000
Re: "C++ on the Move" by Darryl K. Taft kalevi@kolttonen.fi (Kalevi Kolttonen) - 2023-03-14 09:51 +0000
Re: "C++ on the Move" by Darryl K. Taft Muttley@dastardlyhq.com - 2023-03-14 09:56 +0000
Re: "C++ on the Move" by Darryl K. Taft kalevi@kolttonen.fi (Kalevi Kolttonen) - 2023-03-14 10:30 +0000
Re: "C++ on the Move" by Darryl K. Taft David Brown <david.brown@hesbynett.no> - 2023-03-14 13:41 +0100
Re: "C++ on the Move" by Darryl K. Taft Tim Rentsch <tr.17687@z991.linuxsc.com> - 2023-03-14 14:50 -0700
Re: "C++ on the Move" by Darryl K. Taft Tim Rentsch <tr.17687@z991.linuxsc.com> - 2023-03-14 14:13 -0700
Re: "C++ on the Move" by Darryl K. Taft kalevi@kolttonen.fi (Kalevi Kolttonen) - 2023-03-14 21:53 +0000
Re: "C++ on the Move" by Darryl K. Taft Tim Rentsch <tr.17687@z991.linuxsc.com> - 2023-04-04 23:21 -0700
Re: "C++ on the Move" by Darryl K. Taft "james...@alumni.caltech.edu" <jameskuyper@alumni.caltech.edu> - 2023-04-05 08:44 -0700
Re: "C++ on the Move" by Darryl K. Taft legalize+jeeves@mail.xmission.com (Richard) - 2023-04-05 15:47 +0000
Re: "C++ on the Move" by Darryl K. Taft scott@slp53.sl.home (Scott Lurndal) - 2023-04-05 16:33 +0000
Re: "C++ on the Move" by Darryl K. Taft richardthiebaud <thiebauddick2@aol.com> - 2023-04-05 12:53 -0400
Re: "C++ on the Move" by Darryl K. Taft scott@slp53.sl.home (Scott Lurndal) - 2023-04-05 17:19 +0000
Re: "C++ on the Move" by Darryl K. Taft Malcolm McLean <malcolm.arthur.mclean@gmail.com> - 2023-04-05 13:47 -0700
Re: "C++ on the Move" by Darryl K. Taft Muttley@dastardlyhq.com - 2023-04-06 08:12 +0000
Re: "C++ on the Move" by Darryl K. Taft Daniel <danielaparker@gmail.com> - 2023-04-06 05:23 -0700
Re: "C++ on the Move" by Darryl K. Taft Muttley@dastardlyhq.com - 2023-04-06 08:09 +0000
Re: "C++ on the Move" by Darryl K. Taft Tim Rentsch <tr.17687@z991.linuxsc.com> - 2023-07-20 10:02 -0700
Re: "C++ on the Move" by Darryl K. Taft Ben Bacarisse <ben.usenet@bsb.me.uk> - 2023-04-05 21:04 +0100
Re: "C++ on the Move" by Darryl K. Taft Tim Rentsch <tr.17687@z991.linuxsc.com> - 2023-07-20 09:52 -0700
Re: "C++ on the Move" by Darryl K. Taft Ben Bacarisse <ben.usenet@bsb.me.uk> - 2023-07-20 21:01 +0100
Re: "C++ on the Move" by Darryl K. Taft Tim Rentsch <tr.17687@z991.linuxsc.com> - 2023-03-14 08:57 -0700
Re: "C++ on the Move" by Darryl K. Taft Muttley@dastardlyhq.com - 2023-03-14 16:20 +0000
Re: "C++ on the Move" by Darryl K. Taft Malcolm McLean <malcolm.arthur.mclean@gmail.com> - 2023-03-10 07:23 -0800
Re: "C++ on the Move" by Darryl K. Taft David Brown <david.brown@hesbynett.no> - 2023-03-10 16:48 +0100
Re: "C++ on the Move" by Darryl K. Taft David Brown <david.brown@hesbynett.no> - 2023-03-10 15:54 +0100
Re: "C++ on the Move" by Darryl K. Taft Malcolm McLean <malcolm.arthur.mclean@gmail.com> - 2023-03-10 07:12 -0800
Re: "C++ on the Move" by Darryl K. Taft David Brown <david.brown@hesbynett.no> - 2023-03-10 16:53 +0100
Re: "C++ on the Move" by Darryl K. Taft Öö Tiib <ootiib@hot.ee> - 2023-03-10 08:20 -0800
Re: "C++ on the Move" by Darryl K. Taft kalevi@kolttonen.fi (Kalevi Kolttonen) - 2023-03-10 16:48 +0000
Re: "C++ on the Move" by Darryl K. Taft David Brown <david.brown@hesbynett.no> - 2023-03-12 11:54 +0100
Re: "C++ on the Move" by Darryl K. Taft Öö Tiib <ootiib@hot.ee> - 2023-03-12 09:29 -0700
Re: "C++ on the Move" by Darryl K. Taft Malcolm McLean <malcolm.arthur.mclean@gmail.com> - 2023-03-12 09:57 -0700
Re: "C++ on the Move" by Darryl K. Taft Öö Tiib <ootiib@hot.ee> - 2023-03-12 10:26 -0700
Re: "C++ on the Move" by Darryl K. Taft David Brown <david.brown@hesbynett.no> - 2023-03-13 14:40 +0100
Re: "C++ on the Move" by Darryl K. Taft Öö Tiib <ootiib@hot.ee> - 2023-03-13 08:59 -0700
Re: "C++ on the Move" by Darryl K. Taft Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2023-03-12 14:17 -0700
Re: "C++ on the Move" by Darryl K. Taft Öö Tiib <ootiib@hot.ee> - 2023-03-12 16:18 -0700
Re: "C++ on the Move" by Darryl K. Taft David Brown <david.brown@hesbynett.no> - 2023-03-13 14:30 +0100
Re: "C++ on the Move" by Darryl K. Taft Öö Tiib <ootiib@hot.ee> - 2023-03-13 08:25 -0700
Re: "C++ on the Move" by Darryl K. Taft David Brown <david.brown@hesbynett.no> - 2023-03-13 17:54 +0100
Re: "C++ on the Move" by Darryl K. Taft Öö Tiib <ootiib@hot.ee> - 2023-03-14 13:27 -0700
Re: "C++ on the Move" by Darryl K. Taft Paavo Helde <eesnimi@osa.pri.ee> - 2023-03-13 20:37 +0200
Re: "C++ on the Move" by Darryl K. Taft Öö Tiib <ootiib@hot.ee> - 2023-03-14 13:30 -0700
Re: "C++ on the Move" by Darryl K. Taft Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2023-03-13 10:02 -0700
Re: "C++ on the Move" by Darryl K. Taft David Brown <david.brown@hesbynett.no> - 2023-03-13 20:21 +0100
Re: "C++ on the Move" by Darryl K. Taft Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2023-03-13 12:53 -0700
Re: "C++ on the Move" by Darryl K. Taft Tim Rentsch <tr.17687@z991.linuxsc.com> - 2023-03-14 01:17 -0700
Re: "C++ on the Move" by Darryl K. Taft David Brown <david.brown@hesbynett.no> - 2023-03-14 09:55 +0100
Re: "C++ on the Move" by Darryl K. Taft scott@slp53.sl.home (Scott Lurndal) - 2023-03-10 16:27 +0000
Re: "C++ on the Move" by Darryl K. Taft Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2023-03-10 11:33 -0800
Re: "C++ on the Move" by Darryl K. Taft Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2023-03-10 11:14 -0800
Re: "C++ on the Move" by Darryl K. Taft Öö Tiib <ootiib@hot.ee> - 2023-03-11 04:10 -0800
Re: "C++ on the Move" by Darryl K. Taft David Brown <david.brown@hesbynett.no> - 2023-03-12 12:06 +0100
Re: "C++ on the Move" by Darryl K. Taft Öö Tiib <ootiib@hot.ee> - 2023-03-12 09:29 -0700
Re: "C++ on the Move" by Darryl K. Taft Bonita Montero <Bonita.Montero@gmail.com> - 2023-03-09 15:26 +0100
Re: "C++ on the Move" by Darryl K. Taft Lynn McGuire <lynnmcguire5@gmail.com> - 2023-03-09 16:59 -0600
Re: "C++ on the Move" by Darryl K. Taft Bonita Montero <Bonita.Montero@gmail.com> - 2023-03-10 05:59 +0100
Re: "C++ on the Move" by Darryl K. Taft "Alf P. Steinbach" <alf.p.steinbach@gmail.com> - 2023-03-10 09:17 +0100
Re: "C++ on the Move" by Darryl K. Taft Bonita Montero <Bonita.Montero@gmail.com> - 2023-03-10 13:38 +0100
Re: "C++ on the Move" by Darryl K. Taft Michael S <already5chosen@yahoo.com> - 2023-03-10 05:10 -0800
Re: "C++ on the Move" by Darryl K. Taft Bonita Montero <Bonita.Montero@gmail.com> - 2023-03-10 15:20 +0100
Re: "C++ on the Move" by Darryl K. Taft David Brown <david.brown@hesbynett.no> - 2023-03-10 16:13 +0100
Re: "C++ on the Move" by Darryl K. Taft David Brown <david.brown@hesbynett.no> - 2023-03-10 10:44 +0100
Re: "C++ on the Move" by Darryl K. Taft Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2023-03-10 11:08 -0800
Re: "C++ on the Move" by Darryl K. Taft "Alf P. Steinbach" <alf.p.steinbach@gmail.com> - 2023-03-12 11:42 +0100
Re: "C++ on the Move" by Darryl K. Taft "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2023-04-06 00:42 -0700
Page 2 of 8 — ← Prev page 1 [2] 3 4 5 6 7 8 Next page →
| From | James Kuyper <jameskuyper@alumni.caltech.edu> |
|---|---|
| Date | 2023-03-08 18:11 -0500 |
| Message-ID | <tub4na$14fge$1@dont-email.me> |
| In reply to | #89550 |
On 3/8/23 16:34, Alf P. Steinbach wrote: > On 2023-03-08 8:10 PM, James Kuyper wrote: ... >> No, he meant "defining it". If they were to choose to define the >> behavior of signed integer overflow, then on platforms where the defined >> behavior was not the same as that which would naturally occur, run-time >> checks would be required to change the behavior. > > Can you give a concrete (even if hypothetical) example of what you mean? David has already done so. The committee could define the behavior as wrapping, in a fashion compatible with 2's complement behavior. In that case, run-time checks would required on any platform where that wasn't the native behavior - a small number of platforms, to be sure, but they do exist. However, as David pointed out, wrapping is the most useless possible behavior on signed overflow - it almost never gives a useful result. Signed overflow almost always is the result of an error of some kind, and should be treated as such. If the committee were, for example, to choose to define the behavior as calling std::terminate(), it would be more useful, but that would require run-time checks on virtually every existing system.
[toc] | [prev] | [next] | [standalone]
| From | Keith Thompson <Keith.S.Thompson+u@gmail.com> |
|---|---|
| Date | 2023-03-08 12:28 -0800 |
| Message-ID | <87lek7q97n.fsf@nosuchdomain.example.com> |
| In reply to | #89537 |
"Alf P. Steinbach" <alf.p.steinbach@gmail.com> writes:
> On 2023-03-08 6:52 PM, Keith Thompson wrote:
>> Öö Tiib <ootiib@hot.ee> writes:
>>> On Wednesday, 8 March 2023 at 00:26:14 UTC+2, Lynn McGuire wrote:
>>>> On 3/7/2023 4:08 PM, Richard wrote:
>>>>> [Please do not mail me a copy of your followup]
>>>>>
>>>>> Lynn McGuire <lynnmc...@gmail.com> spake the secret code
>>>>> <tu8at1$ijm1$1...@dont-email.me> thusly:
>>>>>
>>>>>> "C++ on the Move" by Darryl K. Taft
>>>>>
>>>>> A ho-hum article IMO. You've posted better :).
>>>>
>>>> I was curious in what people thought of the last paragraph, "“Now bring
>>>> Rust to the table — a language well-suited for the low-level programming
>>>> that C++ typically dominates, but with built-in memory safety and other
>>>> modern features,” Campbell said. “When luminaries like Mark Russinovich
>>>> are saying things like [‘…halt starting any new projects in C/C++ and
>>>> use Rust…’], C++ must evolve or be left behind. The question is, at what
>>>> price?” he said."
>>>> https://twitter.com/markrussinovich/status/1571995117233504257?lang=en
>>>>
>>> Most people agree that C++ contains too lot of features. They only differ
>>> by opinion where to cut. I would put most effort into places where it says
>>> "undefined behavior". I think half of such places can be replaced with
>>> "program is ill formed", "std::terminate is called" or one of the features
>>> that lead to described situation can be cut out (as badly thought thru).
>> I'd be interested in seeing some cases of undefined behavior that
>> could
>> reasonably be detected at compile time or at run time. I'm sure there
>> are some, but I'd be surprised it were as many as half.
>> Just one example: Signed integer overflow has undefined behavior,
>> and
>> defining it would require runtime checks.
>
> I guess you meant to write, "detecting it", not "defining it".
I meant "defining it", as in making the behavior defined rather than
undefined.
> Defining signed overflow as wrap-around requires no runtime checks,
> now that C++ integers are guaranteed two's complement.
Probably true. Two's complement representation doesn't necessarily
imply two's complement behavior on overflow, but that's probably the
default behavior on most platforms.
> Some optimization opportunities would be lost, but maybe others gained.
The only virtue of defining signed overflow as two's complement
wraparound is that it's convenient for the implementation. For users,
it would provide consistency, but having INT_MAX+1 yield INT_MIN is not
likely to be *useful*. If you want the language to define the behavior,
there are a number of options. I wasn't assuming wraparound. (Throwing
an exception is another possibility.)
--
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
Working, but not speaking, for XCOM Labs
void Void(void) { Void(); } /* The recursive call of the void */
[toc] | [prev] | [next] | [standalone]
| From | Michael S <already5chosen@yahoo.com> |
|---|---|
| Date | 2023-03-08 12:48 -0800 |
| Message-ID | <5a9ffd85-dfe6-43ee-9237-87d6e6bb69b9n@googlegroups.com> |
| In reply to | #89546 |
On Wednesday, March 8, 2023 at 10:28:30 PM UTC+2, Keith Thompson wrote:
> "Alf P. Steinbach" <alf.p.s...@gmail.com> writes:
> > On 2023-03-08 6:52 PM, Keith Thompson wrote:
> >> Öö Tiib <oot...@hot.ee> writes:
> >>> On Wednesday, 8 March 2023 at 00:26:14 UTC+2, Lynn McGuire wrote:
> >>>> On 3/7/2023 4:08 PM, Richard wrote:
> >>>>> [Please do not mail me a copy of your followup]
> >>>>>
> >>>>> Lynn McGuire <lynnmc...@gmail.com> spake the secret code
> >>>>> <tu8at1$ijm1$1...@dont-email.me> thusly:
> >>>>>
> >>>>>> "C++ on the Move" by Darryl K. Taft
> >>>>>
> >>>>> A ho-hum article IMO. You've posted better :).
> >>>>
> >>>> I was curious in what people thought of the last paragraph, "“Now bring
> >>>> Rust to the table — a language well-suited for the low-level programming
> >>>> that C++ typically dominates, but with built-in memory safety and other
> >>>> modern features,” Campbell said. “When luminaries like Mark Russinovich
> >>>> are saying things like [‘…halt starting any new projects in C/C++ and
> >>>> use Rust…’], C++ must evolve or be left behind. The question is, at what
> >>>> price?” he said."
> >>>> https://twitter.com/markrussinovich/status/1571995117233504257?lang=en
> >>>>
> >>> Most people agree that C++ contains too lot of features. They only differ
> >>> by opinion where to cut. I would put most effort into places where it says
> >>> "undefined behavior". I think half of such places can be replaced with
> >>> "program is ill formed", "std::terminate is called" or one of the features
> >>> that lead to described situation can be cut out (as badly thought thru).
> >> I'd be interested in seeing some cases of undefined behavior that
> >> could
> >> reasonably be detected at compile time or at run time. I'm sure there
> >> are some, but I'd be surprised it were as many as half.
> >> Just one example: Signed integer overflow has undefined behavior,
> >> and
> >> defining it would require runtime checks.
> >
> > I guess you meant to write, "detecting it", not "defining it".
> I meant "defining it", as in making the behavior defined rather than
> undefined.
> > Defining signed overflow as wrap-around requires no runtime checks,
> > now that C++ integers are guaranteed two's complement.
> Probably true. Two's complement representation doesn't necessarily
> imply two's complement behavior on overflow, but that's probably the
> default behavior on most platforms.
> > Some optimization opportunities would be lost, but maybe others gained.
> The only virtue of defining signed overflow as two's complement
> wraparound is that it's convenient for the implementation. For users,
> it would provide consistency, but having INT_MAX+1 yield INT_MIN is not
> likely to be *useful*.
My favorite example of usefulness of wrapping signed overflow behavior
is CIC (a.k.a. Hogenauer) interpolation and decimation filters.
> If you want the language to define the behavior,
> there are a number of options. I wasn't assuming wraparound. (Throwing
> an exception is another possibility.)
> --
> Keith Thompson (The_Other_Keith) Keith.S.T...@gmail.com
> Working, but not speaking, for XCOM Labs
> void Void(void) { Void(); } /* The recursive call of the void */
[toc] | [prev] | [next] | [standalone]
| From | "Alf P. Steinbach" <alf.p.steinbach@gmail.com> |
|---|---|
| Date | 2023-03-08 22:40 +0100 |
| Message-ID | <tuavbr$13dk4$2@dont-email.me> |
| In reply to | #89547 |
On 2023-03-08 9:48 PM, Michael S wrote: > On Wednesday, March 8, 2023 at 10:28:30 PM UTC+2, Keith Thompson wrote: >> The only virtue of defining signed overflow as two's complement >> wraparound is that it's convenient for the implementation. For users, >> it would provide consistency, but having INT_MAX+1 yield INT_MIN is not >> likely to be *useful*. > > My favorite example of usefulness of wrapping signed overflow behavior > is CIC (a.k.a. Hogenauer) interpolation and decimation filters. In Windows, the millisecond resolution `GetTickCount()` function wraps every 49.7 days. Happily the result is an unsigned type. So, as long as the time between two invocations is less than 49 days, one can simply subtract the last from the first in order to find elapsed time. With signed overflow defined as wrapping that func could have had signed type return value, so as to not cause inadvertent wrapping problems in comparisons and arithmetic involving negative signed type values. So it's a bit about safety, of being able to choose signed type freely. - Alf
[toc] | [prev] | [next] | [standalone]
| From | David Brown <david.brown@hesbynett.no> |
|---|---|
| Date | 2023-03-09 01:12 +0100 |
| Message-ID | <tub89c$14r60$3@dont-email.me> |
| In reply to | #89551 |
On 08/03/2023 22:40, Alf P. Steinbach wrote: > On 2023-03-08 9:48 PM, Michael S wrote: >> On Wednesday, March 8, 2023 at 10:28:30 PM UTC+2, Keith Thompson wrote: >>> The only virtue of defining signed overflow as two's complement >>> wraparound is that it's convenient for the implementation. For users, >>> it would provide consistency, but having INT_MAX+1 yield INT_MIN is not >>> likely to be *useful*. >> >> My favorite example of usefulness of wrapping signed overflow behavior >> is CIC (a.k.a. Hogenauer) interpolation and decimation filters. > > In Windows, the millisecond resolution `GetTickCount()` function wraps > every 49.7 days. Happily the result is an unsigned type. So, as long as > the time between two invocations is less than 49 days, one can simply > subtract the last from the first in order to find elapsed time. > > With signed overflow defined as wrapping that func could have had signed > type return value, so as to not cause inadvertent wrapping problems in > comparisons and arithmetic involving negative signed type values. > > So it's a bit about safety, of being able to choose signed type freely. > Wrapping /can/ occasionally be useful (this kind of things is one such case). Fortunately, there's an easy answer, even if the timers are signed values - convert to unsigned, do the subtraction, convert back to signed (if you want). That is all well-defined behaviour (albeit partially implementation-dependent). As a bit of trivia, Windows 95 had a bug that caused it to crash as soon as that millisecond counter rolled over. The OS had been out for over ten years before the bug was noticed - apparently no one had managed to keep a Windows 95 system running for 49 days without it crashing for some other reason!
[toc] | [prev] | [next] | [standalone]
| From | Keith Thompson <Keith.S.Thompson+u@gmail.com> |
|---|---|
| Date | 2023-03-08 16:27 -0800 |
| Message-ID | <878rg6rcou.fsf@nosuchdomain.example.com> |
| In reply to | #89559 |
David Brown <david.brown@hesbynett.no> writes:
[...]
> As a bit of trivia, Windows 95 had a bug that caused it to crash as
> soon as that millisecond counter rolled over. The OS had been out for
> over ten years before the bug was noticed - apparently no one had
> managed to keep a Windows 95 system running for 49 days without it
> crashing for some other reason!
Or, perhaps more likely, nobody who had a Windows 95 system crash after
49 days ever figured out why it had crashed.
--
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
Working, but not speaking, for XCOM Labs
void Void(void) { Void(); } /* The recursive call of the void */
[toc] | [prev] | [next] | [standalone]
| From | David Brown <david.brown@hesbynett.no> |
|---|---|
| Date | 2023-03-09 13:52 +0100 |
| Message-ID | <tuckqa$1euet$1@dont-email.me> |
| In reply to | #89560 |
On 09/03/2023 01:27, Keith Thompson wrote: > David Brown <david.brown@hesbynett.no> writes: > [...] >> As a bit of trivia, Windows 95 had a bug that caused it to crash as >> soon as that millisecond counter rolled over. The OS had been out for >> over ten years before the bug was noticed - apparently no one had >> managed to keep a Windows 95 system running for 49 days without it >> crashing for some other reason! > > Or, perhaps more likely, nobody who had a Windows 95 system crash after > 49 days ever figured out why it had crashed. > You are spoiling a good legend with realism! :-)
[toc] | [prev] | [next] | [standalone]
| From | Michael S <already5chosen@yahoo.com> |
|---|---|
| Date | 2023-03-09 12:47 -0800 |
| Message-ID | <f37df946-b04d-4a33-a7ec-f128beae2c68n@googlegroups.com> |
| In reply to | #89573 |
On Thursday, March 9, 2023 at 2:52:42 PM UTC+2, David Brown wrote: > On 09/03/2023 01:27, Keith Thompson wrote: > > David Brown <david...@hesbynett.no> writes: > > [...] > >> As a bit of trivia, Windows 95 had a bug that caused it to crash as > >> soon as that millisecond counter rolled over. The OS had been out for > >> over ten years before the bug was noticed - apparently no one had > >> managed to keep a Windows 95 system running for 49 days without it > >> crashing for some other reason! > > > > Or, perhaps more likely, nobody who had a Windows 95 system crash after > > 49 days ever figured out why it had crashed. > > > You are spoiling a good legend with realism! :-) Your story was unrealistic to begin with. Win95 was hardly used by anybody 5 years after its introduction, much less so 10 years after introduction. Win98, esp. Win98 SE, was simply better choice in almost any imaginable situation.
[toc] | [prev] | [next] | [standalone]
| From | David Brown <david.brown@hesbynett.no> |
|---|---|
| Date | 2023-03-09 01:08 +0100 |
| Message-ID | <tub82g$14r60$2@dont-email.me> |
| In reply to | #89547 |
On 08/03/2023 21:48, Michael S wrote: > On Wednesday, March 8, 2023 at 10:28:30 PM UTC+2, Keith Thompson wrote: >> The only virtue of defining signed overflow as two's complement >> wraparound is that it's convenient for the implementation. For users, >> it would provide consistency, but having INT_MAX+1 yield INT_MIN is not >> likely to be *useful*. > > My favorite example of usefulness of wrapping signed overflow behavior > is CIC (a.k.a. Hogenauer) interpolation and decimation filters. > I think that still counts as "not likely to be useful". Yes, two's complement wrapping on overflow is /occasionally/ useful, but only very occasionally. And for many DSP algorithms, saturation would be much more helpful than wrapping. Overflow of fixed-size integers will, in general, give the wrong answer - no matter how it is defined. Therefore, there is no point in defining it to have a particular choice of wrong behaviour, to the detriment of other aspects (such as optimisation, or the freedom for tools or sanitizers to temporarily add run-time checks for debugging). Whatever you do, some basic laws of normal mathematical integer arithmetic will have to be broken - having the overflow behaviour left undefined actually keeps more of them, and more useful laws (such as "x + 1 > x" for any "x") than defined behaviours. If there had to be one single defined behaviour, then saturation is the only reasonable one. If you have a marble jar, and keep adding marbles, it will reach a limit - try to add more, and you will still have the same number of marbles in the jar (and more on the floor). It would be mind-bogglingly insane to suggest that adding one more marble to a full jar would give you a negative jarful of marbles.
[toc] | [prev] | [next] | [standalone]
| From | Malcolm McLean <malcolm.arthur.mclean@gmail.com> |
|---|---|
| Date | 2023-03-09 02:08 -0800 |
| Message-ID | <4c4f4539-0916-45a6-8475-7aa6b80a60b0n@googlegroups.com> |
| In reply to | #89558 |
On Thursday, 9 March 2023 at 00:09:04 UTC, David Brown wrote: > > If there had to be one single defined behaviour, then saturation is the > only reasonable one. If you have a marble jar, and keep adding marbles, > it will reach a limit - try to add more, and you will still have the > same number of marbles in the jar (and more on the floor). It would be > mind-bogglingly insane to suggest that adding one more marble to a full > jar would give you a negative jarful of marbles. > It makes it easy to put in a check. int marbles = N; marbles++; if (marbles < 0) /* This can't happen so we've overflowed. Take action. */ If you saturate, then you have to either put the test in before you do the calculation, which will work for marbles++, but gets more difficult for marbles += N; or you have to say that INT_MAX is an error value for the number of marbles. This is a headache for anyone maintaining the code, as naturally they expect that the number of marbles can go from 0 to INT_MAX inclusive.
[toc] | [prev] | [next] | [standalone]
| From | David Brown <david.brown@hesbynett.no> |
|---|---|
| Date | 2023-03-09 14:06 +0100 |
| Message-ID | <tucljq$1euet$2@dont-email.me> |
| In reply to | #89566 |
On 09/03/2023 11:08, Malcolm McLean wrote:
> On Thursday, 9 March 2023 at 00:09:04 UTC, David Brown wrote:
>>
>> If there had to be one single defined behaviour, then saturation is the
>> only reasonable one. If you have a marble jar, and keep adding marbles,
>> it will reach a limit - try to add more, and you will still have the
>> same number of marbles in the jar (and more on the floor). It would be
>> mind-bogglingly insane to suggest that adding one more marble to a full
>> jar would give you a negative jarful of marbles.
>>
> It makes it easy to put in a check.
>
> int marbles = N;
> marbles++;
> if (marbles < 0)
> /* This can't happen so we've overflowed. Take action. */
>
> If you saturate, then you have to either put the test in before you do the calculation,
> which will work for marbles++, but gets more difficult for marbles += N; or you have
> to say that INT_MAX is an error value for the number of marbles. This is a headache
> for anyone maintaining the code, as naturally they expect that the number of
> marbles can go from 0 to INT_MAX inclusive.
>
I think a "look /before/ you leap" attitude is to be encouraged in
programming - rather than jump first and see what you can learn from the
post-mortem.
if (marbles < INT_MAX) {
marbles++;
} else {
// No room to proceed
}
or for gcc fans:
int m;
if (__builtin_add_overflow(marbles, 1, &m)) {
handle_overflow();
} else {
marbles = m;
}
[toc] | [prev] | [next] | [standalone]
| From | Malcolm McLean <malcolm.arthur.mclean@gmail.com> |
|---|---|
| Date | 2023-03-09 07:14 -0800 |
| Message-ID | <bcb23a5d-6254-4e43-b332-6a996ed8810an@googlegroups.com> |
| In reply to | #89574 |
On Thursday, 9 March 2023 at 13:06:18 UTC, David Brown wrote:
> On 09/03/2023 11:08, Malcolm McLean wrote:
> > On Thursday, 9 March 2023 at 00:09:04 UTC, David Brown wrote:
> >>
> >> If there had to be one single defined behaviour, then saturation is the
> >> only reasonable one. If you have a marble jar, and keep adding marbles,
> >> it will reach a limit - try to add more, and you will still have the
> >> same number of marbles in the jar (and more on the floor). It would be
> >> mind-bogglingly insane to suggest that adding one more marble to a full
> >> jar would give you a negative jarful of marbles.
> >>
> > It makes it easy to put in a check.
> >
> > int marbles = N;
> > marbles++;
> > if (marbles < 0)
> > /* This can't happen so we've overflowed. Take action. */
> >
> > If you saturate, then you have to either put the test in before you do the calculation,
> > which will work for marbles++, but gets more difficult for marbles += N; or you have
> > to say that INT_MAX is an error value for the number of marbles. This is a headache
> > for anyone maintaining the code, as naturally they expect that the number of
> > marbles can go from 0 to INT_MAX inclusive.
> >
> I think a "look /before/ you leap" attitude is to be encouraged in
> programming - rather than jump first and see what you can learn from the
> post-mortem.
>
In which case you can say that signed integer arithmetic has undefined behaviour,
because you catch the overflow before you do the calculation. Which is in fact
the current situation. One benefit of defining the behaviour is so that you can do
it post mortem. The other benefit is that if overflow isn''t handled correctly, the bug
is consistent.
> if (marbles < INT_MAX) {
> marbles++;
> } else {
> // No room to proceed
> }
>
That's how you've got to do it currently. Depending on the flow control, in actual code
it may be more or less difficult to understand than doing the test after the increment.
Defining the behaviour on overflow doesn't prevent you doing it your way, but it gives
you another option.
[toc] | [prev] | [next] | [standalone]
| From | David Brown <david.brown@hesbynett.no> |
|---|---|
| Date | 2023-03-09 20:32 +0100 |
| Message-ID | <tudc88$1iv4n$1@dont-email.me> |
| In reply to | #89576 |
On 09/03/2023 16:14, Malcolm McLean wrote:
> On Thursday, 9 March 2023 at 13:06:18 UTC, David Brown wrote:
>> On 09/03/2023 11:08, Malcolm McLean wrote:
>>> On Thursday, 9 March 2023 at 00:09:04 UTC, David Brown wrote:
>>>>
>>>> If there had to be one single defined behaviour, then saturation is the
>>>> only reasonable one. If you have a marble jar, and keep adding marbles,
>>>> it will reach a limit - try to add more, and you will still have the
>>>> same number of marbles in the jar (and more on the floor). It would be
>>>> mind-bogglingly insane to suggest that adding one more marble to a full
>>>> jar would give you a negative jarful of marbles.
>>>>
>>> It makes it easy to put in a check.
>>>
>>> int marbles = N;
>>> marbles++;
>>> if (marbles < 0)
>>> /* This can't happen so we've overflowed. Take action. */
>>>
>>> If you saturate, then you have to either put the test in before you do the calculation,
>>> which will work for marbles++, but gets more difficult for marbles += N; or you have
>>> to say that INT_MAX is an error value for the number of marbles. This is a headache
>>> for anyone maintaining the code, as naturally they expect that the number of
>>> marbles can go from 0 to INT_MAX inclusive.
>>>
>> I think a "look /before/ you leap" attitude is to be encouraged in
>> programming - rather than jump first and see what you can learn from the
>> post-mortem.
>>
> In which case you can say that signed integer arithmetic has undefined behaviour,
> because you catch the overflow before you do the calculation. Which is in fact
> the current situation.
No, signed integer arithmetic has /defined/ behaviour - it is only
/overflow/ that has undefined behaviour.
> One benefit of defining the behaviour is so that you can do
> it post mortem. The other benefit is that if overflow isn''t handled correctly, the bug
> is consistent.
Consistent bugs are not necessarily better (or rather, less bad) than
inconsistent bugs. It can be helpful if a bug gives a consistent
detectable issue that point to the cause - but equally a consistent bug
could consistently hide the issue and lead you to look elsewhere for the
problem. The idea that consistent incorrect behaviour is better than
undefined behaviour is no more than a myth.
>
>> if (marbles < INT_MAX) {
>> marbles++;
>> } else {
>> // No room to proceed
>> }
>>
> That's how you've got to do it currently. Depending on the flow control, in actual code
> it may be more or less difficult to understand than doing the test after the increment.
> Defining the behaviour on overflow doesn't prevent you doing it your way, but it gives
> you another option.
>
It gives a /worse/ option that encourages bad programming habits. Do
not write code that is broken, and gets things wrong - no matter what
happens afterwards. (Note that this is very different from exceptions
in C++, where throwing an exception is part of the defined and
intentional behaviour of the code.)
But no, the snippet above is /not/ the way you want to handle things
normally. If you are checking for overflow like this, the chances are
that your code is badly designed in the first place. (There are always
exceptions and unusual cases.) You've got to ask yourself /why/ someone
might be trying to add a marble to a full jar in the first place, and
work backwards - somewhere in the earlier code there is likely to be
poorly designed code. Maybe there are too many marbles involved, or the
jar should be bigger, but something is probably wrong.
At the very least, the code should be :
if (marbles < jar_size) {
marbles++;
} else {
// The jar is full - maybe it is time to empty it
}
In real code, the jar would never be INT_MAX in size - thus post-mortem
checks for wrapping overflow cannot be used even if the language defined
integer arithmetic that way. Overflows are bugs - but not necessarily
in the bit of code they appear to be in.
[toc] | [prev] | [next] | [standalone]
| From | Michael S <already5chosen@yahoo.com> |
|---|---|
| Date | 2023-03-09 12:42 -0800 |
| Message-ID | <7611fbf1-86a1-4b0f-9a7c-faf437fffa3an@googlegroups.com> |
| In reply to | #89558 |
On Thursday, March 9, 2023 at 2:09:04 AM UTC+2, David Brown wrote: > On 08/03/2023 21:48, Michael S wrote: > > On Wednesday, March 8, 2023 at 10:28:30 PM UTC+2, Keith Thompson wrote: > > >> The only virtue of defining signed overflow as two's complement > >> wraparound is that it's convenient for the implementation. For users, > >> it would provide consistency, but having INT_MAX+1 yield INT_MIN is not > >> likely to be *useful*. > > > > My favorite example of usefulness of wrapping signed overflow behavior > > is CIC (a.k.a. Hogenauer) interpolation and decimation filters. > > > I think that still counts as "not likely to be useful". Yes, two's > complement wrapping on overflow is /occasionally/ useful, but only very > occasionally. And CIC filters are just one example of very common pattern where even number of integer overflows compensate each other, producing correct final result. What is special in the case of CIC is that the number of overflows can be quite large. In more common case there are exactly two overflows compensating each other, most typically in expression like y1 = y0 + x1 - x0. > And for many DSP algorithms, saturation would be much > more helpful than wrapping. > I did quite a lot of fix-point digital signal processing in the past. In my personal experience saturated arithmeticis pretty much never useful. What is useful, occasionally, is saturating conversion of wider signed type into narrower signed type. > Overflow of fixed-size integers will, in general, give the wrong answer > - no matter how it is defined. Therefore, there is no point in defining > it to have a particular choice of wrong behaviour, to the detriment of > other aspects (such as optimisation, or the freedom for tools or > sanitizers to temporarily add run-time checks for debugging). Whatever > you do, some basic laws of normal mathematical integer arithmetic will > have to be broken - having the overflow behaviour left undefined > actually keeps more of them, and more useful laws (such as "x + 1 > x" > for any "x") than defined behaviours. > > If there had to be one single defined behaviour, then saturation is the > only reasonable one. Absolutely not! Saturation is non-associative, that's enough to take it out of consideration for default behavior. > If you have a marble jar, and keep adding marbles, > it will reach a limit - try to add more, and you will still have the > same number of marbles in the jar (and more on the floor). It would be > mind-bogglingly insane to suggest that adding one more marble to a full > jar would give you a negative jarful of marbles. Somehow, you don't consider almost the same case insane for unsigned integers.
[toc] | [prev] | [next] | [standalone]
| From | David Brown <david.brown@hesbynett.no> |
|---|---|
| Date | 2023-03-10 00:30 +0100 |
| Message-ID | <tudq6g$1ldct$1@dont-email.me> |
| In reply to | #89592 |
On 09/03/2023 21:42, Michael S wrote: > On Thursday, March 9, 2023 at 2:09:04 AM UTC+2, David Brown wrote: >> On 08/03/2023 21:48, Michael S wrote: >>> On Wednesday, March 8, 2023 at 10:28:30 PM UTC+2, Keith Thompson wrote: >> >>>> The only virtue of defining signed overflow as two's complement >>>> wraparound is that it's convenient for the implementation. For users, >>>> it would provide consistency, but having INT_MAX+1 yield INT_MIN is not >>>> likely to be *useful*. >>> >>> My favorite example of usefulness of wrapping signed overflow behavior >>> is CIC (a.k.a. Hogenauer) interpolation and decimation filters. >>> >> I think that still counts as "not likely to be useful". Yes, two's >> complement wrapping on overflow is /occasionally/ useful, but only very >> occasionally. > > > And CIC filters are just one example of very common pattern > where even number of integer overflows compensate each other, > producing correct final result. What is special in the case of CIC is that > the number of overflows can be quite large. In more common case there > are exactly two overflows compensating each other, most typically in > expression like y1 = y0 + x1 - x0. > >> And for many DSP algorithms, saturation would be much >> more helpful than wrapping. >> > > I did quite a lot of fix-point digital signal processing in the past. > In my personal experience saturated arithmeticis pretty much never useful. > What is useful, occasionally, is saturating conversion of wider signed type > into narrower signed type. > >> Overflow of fixed-size integers will, in general, give the wrong answer >> - no matter how it is defined. Therefore, there is no point in defining >> it to have a particular choice of wrong behaviour, to the detriment of >> other aspects (such as optimisation, or the freedom for tools or >> sanitizers to temporarily add run-time checks for debugging). Whatever >> you do, some basic laws of normal mathematical integer arithmetic will >> have to be broken - having the overflow behaviour left undefined >> actually keeps more of them, and more useful laws (such as "x + 1 > x" >> for any "x") than defined behaviours. >> >> If there had to be one single defined behaviour, then saturation is the >> only reasonable one. > > Absolutely not! > Saturation is non-associative, that's enough to take it out of consideration > for default behavior. Wrapping doesn't even follow basic laws on ordering, taking it out of consideration for default behaviour. As I said, overflow will, in general, give incorrect answers. If you choose to define its behaviour, it doesn't matter how you do it, it will regularly be wrong and counter-productive, even if it would be helpful in some use-cases. It will also spoil optimisations for code that does not overflow. If you want wrapping behaviour, make a class that supports that. > >> If you have a marble jar, and keep adding marbles, >> it will reach a limit - try to add more, and you will still have the >> same number of marbles in the jar (and more on the floor). It would be >> mind-bogglingly insane to suggest that adding one more marble to a full >> jar would give you a negative jarful of marbles. > > Somehow, you don't consider almost the same case insane for unsigned integers. > What makes you say that? I think that almost all cases over overflow of unsigned integer arithmetic are the result of bugs in the code. (There are a few idiomatic cases, like "unsigned int x = -1;".) Modulo arithmetic makes more sense for unsigned types than signed types, but it is still usually wrong.
[toc] | [prev] | [next] | [standalone]
| From | scott@slp53.sl.home (Scott Lurndal) |
|---|---|
| Date | 2023-03-10 15:01 +0000 |
| Message-ID | <iDHOL.289813$Ldj8.264650@fx47.iad> |
| In reply to | #89595 |
David Brown <david.brown@hesbynett.no> writes: >On 09/03/2023 21:42, Michael S wrote: >> >> Somehow, you don't consider almost the same case insane for unsigned integers. >> > >What makes you say that? I think that almost all cases over overflow of >unsigned integer arithmetic are the result of bugs in the code. (There >are a few idiomatic cases, like "unsigned int x = -1;".) For that: unsigned int x = ~0u;
[toc] | [prev] | [next] | [standalone]
| From | David Brown <david.brown@hesbynett.no> |
|---|---|
| Date | 2023-03-10 16:38 +0100 |
| Message-ID | <tufiu7$20omv$5@dont-email.me> |
| In reply to | #89628 |
On 10/03/2023 16:01, Scott Lurndal wrote: > David Brown <david.brown@hesbynett.no> writes: >> On 09/03/2023 21:42, Michael S wrote: > >>> >>> Somehow, you don't consider almost the same case insane for unsigned integers. >>> >> >> What makes you say that? I think that almost all cases over overflow of >> unsigned integer arithmetic are the result of bugs in the code. (There >> are a few idiomatic cases, like "unsigned int x = -1;".) > > For that: > > unsigned int x = ~0u; > Yes, but the advantage of the "-1" version is that it scales automatically to the size of the variable - you don't need to write "~0ull" or whatever.
[toc] | [prev] | [next] | [standalone]
| From | scott@slp53.sl.home (Scott Lurndal) |
|---|---|
| Date | 2023-03-10 16:36 +0000 |
| Message-ID | <s0JOL.163907$0XR7.124888@fx07.iad> |
| In reply to | #89633 |
David Brown <david.brown@hesbynett.no> writes: >On 10/03/2023 16:01, Scott Lurndal wrote: >> David Brown <david.brown@hesbynett.no> writes: >>> On 09/03/2023 21:42, Michael S wrote: >> >>>> >>>> Somehow, you don't consider almost the same case insane for unsigned integers. >>>> >>> >>> What makes you say that? I think that almost all cases over overflow of >>> unsigned integer arithmetic are the result of bugs in the code. (There >>> are a few idiomatic cases, like "unsigned int x = -1;".) >> >> For that: >> >> unsigned int x = ~0u; >> > >Yes, but the advantage of the "-1" version is that it scales >automatically to the size of the variable - you don't need to write >"~0ull" or whatever. > You can always use ~0ull and it will be truncated as needed. But I'd argue the programmer should be aware of that caveat when writing the code.
[toc] | [prev] | [next] | [standalone]
| From | David Brown <david.brown@hesbynett.no> |
|---|---|
| Date | 2023-03-11 10:43 +0100 |
| Message-ID | <tuhigt$2e9g4$1@dont-email.me> |
| In reply to | #89642 |
On 10/03/2023 17:36, Scott Lurndal wrote: > David Brown <david.brown@hesbynett.no> writes: >> On 10/03/2023 16:01, Scott Lurndal wrote: >>> David Brown <david.brown@hesbynett.no> writes: >>>> On 09/03/2023 21:42, Michael S wrote: >>> >>>>> >>>>> Somehow, you don't consider almost the same case insane for unsigned integers. >>>>> >>>> >>>> What makes you say that? I think that almost all cases over overflow of >>>> unsigned integer arithmetic are the result of bugs in the code. (There >>>> are a few idiomatic cases, like "unsigned int x = -1;".) >>> >>> For that: >>> >>> unsigned int x = ~0u; >>> >> >> Yes, but the advantage of the "-1" version is that it scales >> automatically to the size of the variable - you don't need to write >> "~0ull" or whatever. >> > > You can always use ~0ull and it will be truncated as needed. But > I'd argue the programmer should be aware of that caveat when writing the > code. The thing I personally find feels slightly wrong about initialising an unsigned variable with -1 is that the value /actually/ assigned does not match the value in the code. That would apply equally to using ~0ull if it had to be truncated. For my type of code, it is normal to use exact width integers, so you know exactly what value you want for all ones - thus I'd normally write "uint16_t x = 0xffff;" or "uint32_t y = 0xffff'ffff;". People and projects have different styles and preferences.
[toc] | [prev] | [next] | [standalone]
| From | Keith Thompson <Keith.S.Thompson+u@gmail.com> |
|---|---|
| Date | 2023-03-08 12:59 -0800 |
| Message-ID | <87h6uvq7s6.fsf@nosuchdomain.example.com> |
| In reply to | #89535 |
Keith Thompson <Keith.S.Thompson+u@gmail.com> writes:
> Öö Tiib <ootiib@hot.ee> writes:
>> On Wednesday, 8 March 2023 at 00:26:14 UTC+2, Lynn McGuire wrote:
>>> On 3/7/2023 4:08 PM, Richard wrote:
>>> > [Please do not mail me a copy of your followup]
>>> >
>>> > Lynn McGuire <lynnmc...@gmail.com> spake the secret code
>>> > <tu8at1$ijm1$1...@dont-email.me> thusly:
>>> >
>>> >> "C++ on the Move" by Darryl K. Taft
>>> >
>>> > A ho-hum article IMO. You've posted better :).
>>>
>>> I was curious in what people thought of the last paragraph, "“Now bring
>>> Rust to the table — a language well-suited for the low-level programming
>>> that C++ typically dominates, but with built-in memory safety and other
>>> modern features,” Campbell said. “When luminaries like Mark Russinovich
>>> are saying things like [‘…halt starting any new projects in C/C++ and
>>> use Rust…’], C++ must evolve or be left behind. The question is, at what
>>> price?” he said."
>>> https://twitter.com/markrussinovich/status/1571995117233504257?lang=en
>>>
>> Most people agree that C++ contains too lot of features. They only differ
>> by opinion where to cut. I would put most effort into places where it says
>> "undefined behavior". I think half of such places can be replaced with
>> "program is ill formed", "std::terminate is called" or one of the features
>> that lead to described situation can be cut out (as badly thought thru).
>
> I'd be interested in seeing some cases of undefined behavior that could
> reasonably be detected at compile time or at run time. I'm sure there
> are some, but I'd be surprised it were as many as half.
>
> Just one example: Signed integer overflow has undefined behavior, and
> defining it would require runtime checks.
Perhaps it would have been better if I hadn't provided an example.
Nothing wrong with talking about signed integer overflow, but it wasn't
what I intended to focus on.
Öö Tiib speculated that about half of the cases of undefined behavior
could be replaced by "program is ill formed" (detectable at compile
time) or "std::terminate is called" (detectable at run time).
I'm sure that *some* cases of undefined behavior could be made
not-undefined, but I'm skeptical that as many as half could be.
(Counting cases of UB is tricky, especially given the cases that are
undefined by omission.)
--
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
Working, but not speaking, for XCOM Labs
void Void(void) { Void(); } /* The recursive call of the void */
[toc] | [prev] | [next] | [standalone]
Page 2 of 8 — ← Prev page 1 [2] 3 4 5 6 7 8 Next page →
Back to top | Article view | comp.lang.c++
csiph-web