Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
| From | Keith Thompson <kst-u@mib.org> |
|---|---|
| Newsgroups | comp.lang.c |
| Subject | Re: Defined and undefined C pointer manipulation |
| Date | 2014-04-27 13:16 -0700 |
| Organization | None to speak of |
| Message-ID | <lnr44iply4.fsf@nuthaus.mib.org> (permalink) |
| References | <ljgqns$t1i$1@dont-email.me> <pointers-20140426195429@ram.dialup.fu-berlin.de> <ljjhvo$9o6$1@dont-email.me> <Lpc7v.64776$rL7.53357@en-nntp-16.dc1.easynews.com> <ljjn6a$ej7$1@dont-email.me> |
"James Harris" <james.harris.1@gmail.com> writes:
> "Richard Damon" <Richard@Damon-Family.org> wrote in message
> news:Lpc7v.64776$rL7.53357@en-nntp-16.dc1.easynews.com...
[...]
>> Having a pointer type as one of the parameters to a bitwise operator is
>> a constraint violation that REQUIRES a diagnostic.
>
> Out of interest, why is a diagnostic required?
Because the standard says so.
The relevant wording has already been cited, but I'll quote a bit more
of it here:
N1570 6.5.11 Bitwise exclusive OR operator
Syntax
...
Constraints
Each of the operands shall have integer type.
There's no wiggle room there. If either operand has a non-integer type,
a constraint is violated and a diagnostic is required.
> Do the clauses below apply
> only to explicit conversions? I see in n869 (which is not, AFAIK,
> authoritative):
>
> 6.3.2.3 Pointers
>
> 5 An integer may be converted to any pointer type. Except as previously
> specified, the result is implementation-defined, might not be properly
> aligned, and might not point to an entity of the referenced type.49)
Yes, an integer type may be converted to any pointer type -- but the
conversions that may be done implicitly are described elsewhere, and do
*not* include any pointer-to-integer conversions.
[...]
> Section 6.3 speaks about implicit conversions and refers to the conversions
> performed *by most ordinary operators* in 6.3.1.8 which gives the "Usual
> arithmetic conversions" and after speaking about floating point promotions
> it says:
>
> Otherwise, the integer promotions are performed on both operands. Then the
> following rules are applied to the promoted operands...
> Doesn't that state the integer promotions are performed on both operands
> irrespective of whether one is a pointer or not?
The "usual arithmetic conversions" and "integer promotions" never apply
to pointers, as you can see if you read the descriptions of those terms.
--
Keith Thompson (The_Other_Keith) kst-u@mib.org <http://www.ghoti.net/~kst>
Working, but not speaking, for JetHead Development, Inc.
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Defined and undefined C pointer manipulation "James Harris" <james.harris.1@gmail.com> - 2014-04-26 18:35 +0100
Re: Defined and undefined C pointer manipulation Keith Thompson <kst-u@mib.org> - 2014-04-26 12:04 -0700
Re: Defined and undefined C pointer manipulation "James Harris" <james.harris.1@gmail.com> - 2014-04-27 19:11 +0100
Re: Defined and undefined C pointer manipulation Barry Schwarz <schwarzb@dqel.com> - 2014-04-27 11:46 -0700
Re: Defined and undefined C pointer manipulation Keith Thompson <kst-u@mib.org> - 2014-04-27 12:46 -0700
Re: Defined and undefined C pointer manipulation Ben Bacarisse <ben.usenet@bsb.me.uk> - 2014-04-28 02:53 +0100
Re: Defined and undefined C pointer manipulation Keith Thompson <kst-u@mib.org> - 2014-04-27 12:57 -0700
Re: Defined and undefined C pointer manipulation "James Harris" <james.harris.1@gmail.com> - 2014-04-27 21:56 +0100
Re: Defined and undefined C pointer manipulation Keith Thompson <kst-u@mib.org> - 2014-04-27 14:25 -0700
Re: Defined and undefined C pointer manipulation glen herrmannsfeldt <gah@ugcs.caltech.edu> - 2014-04-27 22:51 +0000
Re: Defined and undefined C pointer manipulation Malcolm McLean <malcolm.mclean5@btinternet.com> - 2014-04-27 06:21 -0700
Re: Defined and undefined C pointer manipulation "BartC" <bc@freeuk.com> - 2014-04-27 16:51 +0100
Re: Defined and undefined C pointer manipulation Malcolm McLean <malcolm.mclean5@btinternet.com> - 2014-04-27 10:36 -0700
Re: Defined and undefined C pointer manipulation Ian Collins <ian-news@hotmail.com> - 2014-04-28 11:40 +1200
Re: Defined and undefined C pointer manipulation "James Harris" <james.harris.1@gmail.com> - 2014-04-27 19:23 +0100
Re: Defined and undefined C pointer manipulation Richard Damon <Richard@Damon-Family.org> - 2014-04-27 14:56 -0400
Re: Defined and undefined C pointer manipulation "James Harris" <james.harris.1@gmail.com> - 2014-04-27 20:52 +0100
Re: Defined and undefined C pointer manipulation Keith Thompson <kst-u@mib.org> - 2014-04-27 13:16 -0700
Re: Defined and undefined C pointer manipulation "BartC" <bc@freeuk.com> - 2014-04-27 20:55 +0100
Re: Defined and undefined C pointer manipulation "James Harris" <james.harris.1@gmail.com> - 2014-04-27 21:20 +0100
Re: Defined and undefined C pointer manipulation glen herrmannsfeldt <gah@ugcs.caltech.edu> - 2014-04-27 22:39 +0000
Re: Defined and undefined C pointer manipulation glen herrmannsfeldt <gah@ugcs.caltech.edu> - 2014-04-27 22:43 +0000
Re: Defined and undefined C pointer manipulation "BartC" <bc@freeuk.com> - 2014-04-28 00:13 +0100
Re: Defined and undefined C pointer manipulation Keith Thompson <kst-u@mib.org> - 2014-04-27 13:01 -0700
Re: Defined and undefined C pointer manipulation James Kuyper <jameskuyper@verizon.net> - 2014-04-27 22:07 -0400
Re: Defined and undefined C pointer manipulation Malcolm McLean <malcolm.mclean5@btinternet.com> - 2014-04-28 00:47 -0700
Re: Defined and undefined C pointer manipulation Ian Collins <ian-news@hotmail.com> - 2014-04-28 20:01 +1200
Re: Defined and undefined C pointer manipulation Malcolm McLean <malcolm.mclean5@btinternet.com> - 2014-04-28 02:11 -0700
Re: Defined and undefined C pointer manipulation Ian Collins <ian-news@hotmail.com> - 2014-04-28 22:38 +1200
Re: Defined and undefined C pointer manipulation Malcolm McLean <malcolm.mclean5@btinternet.com> - 2014-04-28 04:50 -0700
Re: Defined and undefined C pointer manipulation "BartC" <bc@freeuk.com> - 2014-04-28 09:22 +0100
Re: Defined and undefined C pointer manipulation Malcolm McLean <malcolm.mclean5@btinternet.com> - 2014-04-28 05:31 -0700
csiph-web