Skip to Content.
Sympa Menu

c-semantics - Re: [C-Semantics] C question about const

c-semantics AT lists.cs.illinois.edu

Subject: C Semantics in K Framework

List archive

Re: [C-Semantics] C question about const


Chronological Thread 
  • From: Derek M Jones <derek AT knosof.co.uk>
  • To: Chucky Ellison <cme AT freefour.com>
  • Cc: Dwight Guth <dguth2 AT illinois.edu>, "c-semantics AT cs.illinois.edu" <c-semantics AT cs.illinois.edu>, chris hathhorn <hathhorn AT gmail.com>, Pascal Cuoq <pascal.cuoq AT gmail.com>
  • Subject: Re: [C-Semantics] C question about const
  • Date: Sat, 21 Feb 2015 01:44:55 +0000
  • List-archive: <http://lists.cs.uiuc.edu/pipermail/c-semantics/>
  • List-id: C Semantics in K Framework <c-semantics.cs.illinois.edu>
  • Organization: Knowledge Software, Ltd

Chucky,

Doesn't being a constraint violation make it undefined? I can't really

A constraint violation means the that program is erroneous and need not
be translated by a conforming implementation.

Of course a conforming implementation can translation an erroneous
program, but the behavior is undefined (3.4.3p1). There is nothing
that says a C compiler cannot process Fortran source as if it were
a Fortran compiler.

What is special about your example?

find what the point of constraints are in the standard, but I've always
assumed constraint violations were undefined.

All I can find talking around it are

- constraint: "restriction, either syntactic or semantic, by which the
exposition of language elements is to be interpreted"
and then this beast
- If a ‘‘shall’’ or ‘‘shall not’’ requirement that appears outside of a
constraint or runtime-constraint is violated, the behavior is undefined.
This seems to leave unexplained what happens if a shall or shall not
requirement that appears INSIDE a constraint or runtime-constraint is
violated, but its existence may imply it's not undefined.

At any rate, the behavior certainly doesn't seem DEFINED.

What gives? And what do you think about how not being able to cast away
const means we can't keep const pointers we eventually free? Seems
limiting to me.

-Chucky

On Thu, Feb 19, 2015 at 9:47 AM, Derek M Jones
<derek AT knosof.co.uk>
wrote:

Chucky,

Good to hear from you. Hope you are having fun.

int * p3 = p2; // I think this is undefined, since the case is not listed
in 6.3.2.3 or anywhere else I can tell


Its a constraint violation, 6.7.8p11 -> 6.5.16.1p1


--
Derek M. Jones Software analysis
tel: +44 (0)1252 520667 blog:shape-of-code.coding-guidelines.com



--
Derek M. Jones Software analysis
tel: +44 (0)1252 520667 blog:shape-of-code.coding-guidelines.com





Archive powered by MHonArc 2.6.16.

Top of Page