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: *&aptr , &*aptr question |
| Date | 2016-06-14 16:51 -0700 |
| Organization | None to speak of |
| Message-ID | <lninxb1g9k.fsf@kst-u.example.com> (permalink) |
| References | (1 earlier) <12ba4330-5009-077d-83d8-3e41a7221f7f@verizon.net> <njpul4$eiv$1@dont-email.me> <81f2561c-bea5-4846-9d10-9862764110ef@googlegroups.com> <lvalue-20160614232823@ram.dialup.fu-berlin.de> <njq1ud$sam$1@dont-email.me> |
BartC <bc@freeuk.com> writes:
[...]
> What's going on here then:
>
> int* Ptr;
>
> Ptr = Ptr;
> Ptr = *Ptr;
> Ptr = &Ptr;
> Ptr = &*Ptr;
> Ptr = *&Ptr;
>
> Ptr = &*&Ptr;
> Ptr = *&*Ptr;
>
> Ptr = &*&*Ptr;
> Ptr = *&*&Ptr;
>
> These are all fine according to gcc (and TCC and clang; other compilers
> aren't quite so happy).
What do you mean by "fine"? Did you not get warnings?
gcc is notorious for issuing non-fatal warnings by default for some
constraint violations. Surely you've seen that mentioned here before.
I get:
c.c: In function ‘main’:
c.c:7:9: warning: assignment makes pointer from integer without a cast
[enabled by default]
Ptr = *Ptr;
^
c.c:8:9: warning: assignment from incompatible pointer type [enabled by
default]
Ptr = &Ptr;
^
c.c:12:9: warning: assignment from incompatible pointer type [enabled by
default]
Ptr = &*&Ptr;
^
c.c:13:9: warning: assignment makes pointer from integer without a cast
[enabled by default]
Ptr = *&*Ptr;
^
If you really didn't get any warnings, what version of gcc are you
using?
If you did, why the &*&* didn't you mention that fact? (Use the
-pedantic-errors option if you want fatal errors for constraint
violations.)
(Of course the standard only requires a diagnostic message, so this
isn't a conformance violation.)
--
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
*&aptr , &*aptr question G G <gdotone@gmail.com> - 2016-06-14 13:43 -0700
Re: *&aptr , &*aptr question Richard Heathfield <rjh@cpax.org.uk> - 2016-06-14 22:01 +0100
Re: *&aptr , &*aptr question Ike Naar <ike@iceland.freeshell.org> - 2016-06-14 21:20 +0000
Re: *&aptr , &*aptr question G G <gdotone@gmail.com> - 2016-06-14 14:38 -0700
Re: *&aptr , &*aptr question Richard Heathfield <rjh@cpax.org.uk> - 2016-06-14 22:42 +0100
Re: *&aptr , &*aptr question Ken Brody <kenbrody@spamcop.net> - 2016-06-15 14:22 -0400
Re: *&aptr , &*aptr question Richard Heathfield <rjh@cpax.org.uk> - 2016-06-15 19:24 +0100
Re: *&aptr , &*aptr question "James R. Kuyper" <jameskuyper@verizon.net> - 2016-06-14 17:17 -0400
Re: *&aptr , &*aptr question Keith Thompson <kst-u@mib.org> - 2016-06-14 14:37 -0700
Re: *&aptr , &*aptr question "James R. Kuyper" <jameskuyper@verizon.net> - 2016-06-14 17:40 -0400
Re: *&aptr , &*aptr question "James R. Kuyper" <jameskuyper@verizon.net> - 2016-06-14 17:49 -0400
Re: *&aptr , &*aptr question BartC <bc@freeuk.com> - 2016-06-14 22:57 +0100
Re: *&aptr , &*aptr question jameskuyper@verizon.net - 2016-06-14 15:22 -0700
Re: *&aptr , &*aptr question "James R. Kuyper" <jameskuyper@verizon.net> - 2016-06-14 18:40 -0400
Re: *&aptr , &*aptr question BartC <bc@freeuk.com> - 2016-06-14 23:44 +0100
Re: *&aptr , &*aptr question BartC <bc@freeuk.com> - 2016-06-14 23:54 +0100
Re: *&aptr , &*aptr question Ben Bacarisse <ben.usenet@bsb.me.uk> - 2016-06-15 00:14 +0100
Re: *&aptr , &*aptr question Keith Thompson <kst-u@mib.org> - 2016-06-14 16:51 -0700
Re: *&aptr , &*aptr question BartC <bc@freeuk.com> - 2016-06-15 01:15 +0100
Re: *&aptr , &*aptr question Keith Thompson <kst-u@mib.org> - 2016-06-14 17:44 -0700
Re: *&aptr , &*aptr question David Brown <david.brown@hesbynett.no> - 2016-06-15 09:12 +0200
Re: *&aptr , &*aptr question Richard Heathfield <rjh@cpax.org.uk> - 2016-06-15 08:28 +0100
Re: *&aptr , &*aptr question David Brown <david.brown@hesbynett.no> - 2016-06-15 10:26 +0200
Re: *&aptr , &*aptr question Richard Heathfield <rjh@cpax.org.uk> - 2016-06-15 09:48 +0100
Re: *&aptr , &*aptr question BartC <bc@freeuk.com> - 2016-06-15 11:05 +0100
Re: *&aptr , &*aptr question David Brown <david.brown@hesbynett.no> - 2016-06-15 12:22 +0200
Re: *&aptr , &*aptr question Malcolm McLean <malcolm.mclean5@btinternet.com> - 2016-06-15 03:55 -0700
Re: *&aptr , &*aptr question David Brown <david.brown@hesbynett.no> - 2016-06-15 13:15 +0200
Re: *&aptr , &*aptr question BartC <bc@freeuk.com> - 2016-06-15 13:08 +0100
Re: *&aptr , &*aptr question David Brown <david.brown@hesbynett.no> - 2016-06-15 14:15 +0200
Re: *&aptr , &*aptr question BartC <bc@freeuk.com> - 2016-06-15 14:02 +0100
Re: *&aptr , &*aptr question Malcolm McLean <malcolm.mclean5@btinternet.com> - 2016-06-15 13:38 -0700
Re: *&aptr , &*aptr question David Brown <david.brown@hesbynett.no> - 2016-06-16 00:01 +0200
Re: *&aptr , &*aptr question Malcolm McLean <malcolm.mclean5@btinternet.com> - 2016-06-16 00:58 -0700
Re: *&aptr , &*aptr question supercat@casperkitty.com - 2016-06-15 09:06 -0700
Re: *&aptr , &*aptr question BartC <bc@freeuk.com> - 2016-06-15 17:54 +0100
Re: *&aptr , &*aptr question raltbos@xs4all.nl (Richard Bos) - 2016-06-15 20:10 +0000
Re: *&aptr , &*aptr question supercat@casperkitty.com - 2016-06-14 16:28 -0700
Re: *&aptr , &*aptr question Keith Thompson <kst-u@mib.org> - 2016-06-14 16:54 -0700
Re: *&aptr , &*aptr question supercat@casperkitty.com - 2016-06-14 19:13 -0700
Re: *&aptr , &*aptr question Ben Bacarisse <ben.usenet@bsb.me.uk> - 2016-06-15 13:19 +0100
Re: *&aptr , &*aptr question Tim Rentsch <txr@alumni.caltech.edu> - 2016-06-16 10:39 -0700
Re: *&aptr , &*aptr question supercat@casperkitty.com - 2016-06-16 12:06 -0700
Re: *&aptr , &*aptr question Tim Rentsch <txr@alumni.caltech.edu> - 2016-06-21 12:21 -0700
Re: *&aptr , &*aptr question Ben Bacarisse <ben.usenet@bsb.me.uk> - 2016-06-16 21:06 +0100
Re: *&aptr , &*aptr question supercat@casperkitty.com - 2016-06-16 14:35 -0700
Re: *&aptr , &*aptr question Ben Bacarisse <ben.usenet@bsb.me.uk> - 2016-06-17 01:22 +0100
Re: *&aptr , &*aptr question Tim Rentsch <txr@alumni.caltech.edu> - 2016-06-16 22:21 -0700
Re: *&aptr , &*aptr question Ben Bacarisse <ben.usenet@bsb.me.uk> - 2016-06-18 00:55 +0100
Re: *&aptr , &*aptr question supercat@casperkitty.com - 2016-06-17 17:26 -0700
Re: *&aptr , &*aptr question Tim Rentsch <txr@alumni.caltech.edu> - 2016-06-21 12:19 -0700
Re: *&aptr , &*aptr question supercat@casperkitty.com - 2016-06-21 13:09 -0700
Re: *&aptr , &*aptr question Eric Sosman <esosman@comcast-dot-net.invalid> - 2016-06-14 22:30 -0400
Re: *&aptr , &*aptr question Tim Rentsch <txr@alumni.caltech.edu> - 2016-06-15 14:20 -0700
csiph-web