Topic: Standard inconsistencies?
Author: "Bill Wade" <wrwade@swbell.net>
Date: Sat, 30 Mar 2002 03:12:37 GMT Raw View
"Krzysztof Parzyszek" <hektor@iname.com> wrote in message
news:slrna9qeft.1m4r.hektor@antares.stures.iastate.edu...
> I have found two places in the standard that seem to me to be
> inconsistent:
>
> 1. Section 3.9.1, paragraph 4 says that unsigned integer types obey
> the laws of arithmetic modulo 2^n. Section 5, paragraph 5 says that
> if the result is not in the range of its type, the behavior is
> undefined (doesn't mention unsigned integers).
When the arithmetic is mod 2^n, the result will usually be in range. When
it isn't (such as division by zero) the behavior is undefined.
> 2. Section 5, paragraph 4 states that any scalar object shall have
> its value modified at most once between two consecutive sequence
> points. I believe that violation of this rule causes undefined
> behavior, but the first and the third example describe such behavior
> as ``unspecified''.
I believe you are correct.
> Please correct me if I'm wrong. In particular I'd appreciate
> some explanation on meaning of ``shall'' and ``shall not'':
> am I correct that violation of these causes undefined behavior?
> The standard doesn't seem to mention that.
I agree.
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.research.att.com/~austern/csc/faq.html ]
Author: Krzysztof Parzyszek <hektor@iname.com>
Date: Sun, 24 Mar 2002 06:40:10 GMT Raw View
I have found two places in the standard that seem to me to be
inconsistent:
1. Section 3.9.1, paragraph 4 says that unsigned integer types obey
the laws of arithmetic modulo 2^n. Section 5, paragraph 5 says that
if the result is not in the range of its type, the behavior is
undefined (doesn't mention unsigned integers).
2. Section 5, paragraph 4 states that any scalar object shall have
its value modified at most once between two consecutive sequence
points. I believe that violation of this rule causes undefined
behavior, but the first and the third example describe such behavior
as ``unspecified''.
Please correct me if I'm wrong. In particular I'd appreciate
some explanation on meaning of ``shall'' and ``shall not'':
am I correct that violation of these causes undefined behavior?
The standard doesn't seem to mention that.
--
<>> hektor@iname.com <Krzysztof Parzyszek> Visit http://google.com
<<> (E)-N-[(4-Hydroxy-3-methoxyphenyl)methyl]-8-methyl-6-nonenamide
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.research.att.com/~austern/csc/faq.html ]