Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c > #104412
| Newsgroups | comp.lang.c |
|---|---|
| Date | 2017-02-22 14:43 -0800 |
| References | (4 earlier) <idgrac1th0dk144r2niokdbstdc51ct8s9@4ax.com> <20170222175222.30c839c809d4d6c6b005274f@gmail.com> <o8kteq$hj3$1@dont-email.me> <35ac8d68-6fc3-4bc7-811d-2ab8a893c215@googlegroups.com> <87h93l7ux1.fsf@bsb.me.uk> |
| Message-ID | <4f758d75-e0d2-426f-858f-668e19f7cd87@googlegroups.com> (permalink) |
| Subject | Re: modifying local const variable run time |
| From | supercat@casperkitty.com |
On Wednesday, February 22, 2017 at 3:55:14 PM UTC-6, Ben Bacarisse wrote:
> Is this an example of undefined behaviour you are describing:
>
> int main(void)
> {
> int something = 1;
> void const * const restrict arbitraryName = &something;
> something = 0;
> return something;
> }
>
> If so, can you say why it's undefined? I can see only one lvalue being
> used (something) and a pointer to it (&something) is not an expression
> based on arbitraryName. Have I misunderstood?
I forgot to add a dummy access via the pointer, but N1570 6.7.3.1 [Formal
definition of restrict] paragraph 4 specifies that if an object is accessed
via a restrict qualified pointer or any pointer derived therefrom and is
modified by any means, the restrict-qualified pointer most not also be
const-qualified; violation of that restriction invokes UB.
Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
modifying local const variable run time rahul.dev.agg@gmail.com - 2017-02-22 06:39 -0800
Re: modifying local const variable run time GOTHIER Nathan <nathan.gothier@gmail.com> - 2017-02-22 16:06 +0100
Re: modifying local const variable run time rahul.dev.agg@gmail.com - 2017-02-22 07:26 -0800
Re: modifying local const variable run time David Brown <david.brown@hesbynett.no> - 2017-02-22 16:31 +0100
Re: modifying local const variable run time rahul.dev.agg@gmail.com - 2017-02-22 07:43 -0800
Re: modifying local const variable run time Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-02-22 16:06 +0000
Re: modifying local const variable run time James Kuyper <jameskuyper@verizon.net> - 2017-02-22 11:13 -0500
Re: modifying local const variable run time supercat@casperkitty.com - 2017-02-22 08:34 -0800
Re: modifying local const variable run time David Brown <david.brown@hesbynett.no> - 2017-02-22 23:03 +0100
Re: modifying local const variable run time GOTHIER Nathan <nathan.gothier@gmail.com> - 2017-02-22 17:34 +0100
Re: modifying local const variable run time Robert Wessel <robertwessel2@yahoo.com> - 2017-02-22 10:52 -0600
Re: modifying local const variable run time GOTHIER Nathan <nathan.gothier@gmail.com> - 2017-02-22 17:52 +0100
Re: modifying local const variable run time Keith Thompson <kst-u@mib.org> - 2017-02-22 09:33 -0800
Re: modifying local const variable run time James Kuyper <jameskuyper@verizon.net> - 2017-02-22 15:50 -0500
Re: modifying local const variable run time supercat@casperkitty.com - 2017-02-22 13:13 -0800
Re: modifying local const variable run time Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-02-22 21:55 +0000
Re: modifying local const variable run time supercat@casperkitty.com - 2017-02-22 14:43 -0800
Re: modifying local const variable run time Keith Thompson <kst-u@mib.org> - 2017-02-22 09:23 -0800
Re: modifying local const variable run time GOTHIER Nathan <nathan.gothier@gmail.com> - 2017-02-22 18:32 +0100
Re: modifying local const variable run time Keith Thompson <kst-u@mib.org> - 2017-02-22 09:50 -0800
Re: modifying local const variable run time David Brown <david.brown@hesbynett.no> - 2017-02-22 23:07 +0100
Re: modifying local const variable run time Keith Thompson <kst-u@mib.org> - 2017-02-22 15:20 -0800
Re: modifying local const variable run time David Brown <david.brown@hesbynett.no> - 2017-02-23 09:50 +0100
Re: modifying local const variable run time James Kuyper <jameskuyper@verizon.net> - 2017-02-22 10:16 -0500
Re: modifying local const variable run time Keith Thompson <kst-u@mib.org> - 2017-02-22 09:17 -0800
csiph-web