Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > Re: Constraint violation - when?

Reply
Thread Tools

Re: Constraint violation - when?

 
 
James Kuyper
Guest
Posts: n/a
 
      07-30-2008
Pietro Cerutti wrote:
> Dear all,
>
> I would like to open another topic to try to clarify a doubt raised on
> my previous post today with the subject 'printf("%d%d%d")'.
>
> Reading through the standard, I cannot find a clear definition of what
> is a constraint violation.
>
> Repeating the citation:
> 3.8
> 1 constraint
> restriction, either syntactic or semantic, by which the exposition
> of language elements is to be interpreted


I agree that this description is quite elliptic; I've never been able to
attach any clear meaning to the part after the second comma. However,
all is not lost --

> As I understand it, a constraint is any explicit syntax or semantic rule.


Whatever it is that they meant to say in the definition above, it
appears, from the way the standard uses the term, that syntax rules are
distinct from syntactic constraints, and that semantic rules are
distinct from semantic constraints.

All you have to do to identify a constraint is to look at the title of
the section where you found it. If that title is "constraints", then
it's a constraint; otherwise it's something else. Exception:
5.1.2.2.1p2, 6.10p2.

Lawrence Jones: wouldn't it be more consistent if 5.1.2.2.1p2 and 6.10p2
were not exceptions to this pattern?
 
Reply With Quote
 
 
 
 
Keith Thompson
Guest
Posts: n/a
 
      07-30-2008
James Kuyper <(E-Mail Removed)> writes:
[...]
> All you have to do to identify a constraint is to look at the title of
> the section where you found it. If that title is "constraints", then
> it's a constraint; otherwise it's something else. Exception:
> 5.1.2.2.1p2, 6.10p2.
>
> Lawrence Jones: wouldn't it be more consistent if 5.1.2.2.1p2 and
> 6.10p2 were not exceptions to this pattern?


In 5.1.2.2.1p2:

If they are declared, the parameters to the main function shall
obey the following constraints:
...

the word "constraints" is being used in a manner that's consistent
with the vague definition in 3.8, but not with the general usage of
the term "constraint" as a requirement whose violation can be
diagnosed at compile time.

The use of term "constraints" in 6.10p2 is also rather odd. Something
that violates the listed "constraints" isn't necessarily a diagnosable
error; it's just not a preprocessing directive.

--
Keith Thompson (The_Other_Keith) http://www.velocityreviews.com/forums/(E-Mail Removed) <http://www.ghoti.net/~kst>
Nokia
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
 
Reply With Quote
 
 
 
 
jameskuyper@verizon.net
Guest
Posts: n/a
 
      07-30-2008
Keith Thompson wrote:
> James Kuyper <(E-Mail Removed)> writes:
> [...]
> > All you have to do to identify a constraint is to look at the title of
> > the section where you found it. If that title is "constraints", then
> > it's a constraint; otherwise it's something else. Exception:
> > 5.1.2.2.1p2, 6.10p2.
> >
> > Lawrence Jones: wouldn't it be more consistent if 5.1.2.2.1p2 and
> > 6.10p2 were not exceptions to this pattern?


Note: I got an autormated reply that he's on vacation until 8/11
>
> In 5.1.2.2.1p2:
>
> If they are declared, the parameters to the main function shall
> obey the following constraints:
> ...
>
> the word "constraints" is being used in a manner that's consistent
> with the vague definition in 3.8, but not with the general usage of
> the term "constraint" as a requirement whose violation can be
> diagnosed at compile time.


Yes, those are run-time constraints on the implementation, rather than
compile-time constraints on the program.

> The use of term "constraints" in 6.10p2 is also rather odd. Something
> that violates the listed "constraints" isn't necessarily a diagnosable
> error; it's just not a preprocessing directive.


You're right: I just did a quick search for "constraint". I thought
those were just a couple of inconsistencies that slipped past the
editor. If I'd thought about it a little longer, I'd have realize why
these two were handled differently than the other "contraint"
sections.
 
Reply With Quote
 
lawrence.jones@siemens.com
Guest
Posts: n/a
 
      08-13-2008
James Kuyper <(E-Mail Removed)> wrote:
> Pietro Cerutti wrote:
> >
> > Repeating the citation:
> > 3.8
> > 1 constraint
> > restriction, either syntactic or semantic, by which the exposition
> > of language elements is to be interpreted

>
> I agree that this description is quite elliptic; I've never been able to
> attach any clear meaning to the part after the second comma.


Originally (way back when that definition was written), the philosophy
was that constraints were what told you whether a string of characters
was actually a C translation unit or just a string of characters. The
primary thing that does that is the syntax grammar rules, but there are
some rules that are difficult (if not impossible) to represent in the
syntax, so they are stated in plain text in specially labeled sections
instead. For example, the grammar is ambiguous as to whether the
characters ``<foo>'' should be interpreted as a header name or as a
less-than operator, an identifier, and a greater-than operator; that was
disambiguated by a constraint that said that header names are only
recognized in #include directives. So the constraints were viewed as an
adjuct to the grammar, which tells you how to interpret (parse) the
language elements.

The grammar has since been revised and that constraint revised and moved
to semantics (and that's the only example I can think of where a
constraint actually affected the grammar), and the grammar rules are no
longer viewed as contraints but as something separate, so the definition
now leaves something to be desired, but not enough that anyone (on the
committee) has felt a burning need to change it.
--
Larry Jones

You should see me when I lose in real life! -- Calvin

 
Reply With Quote
 
jameskuyper@verizon.net
Guest
Posts: n/a
 
      08-13-2008
(E-Mail Removed) wrote:
> James Kuyper <(E-Mail Removed)> wrote:
> > Pietro Cerutti wrote:
> > >
> > > Repeating the citation:
> > > 3.8
> > > 1 constraint
> > > restriction, either syntactic or semantic, by which the exposition
> > > of language elements is to be interpreted

> >
> > I agree that this description is quite elliptic; I've never been able to
> > attach any clear meaning to the part after the second comma.

>
> Originally (way back when that definition was written), the philosophy
> was that constraints were what told you whether a string of characters
> was actually a C translation unit or just a string of characters.


I find that explanation much clearer than the standard's wording,
though it would probably need to be a little more formal before it
could be adopted as a replacement for the current definition. If it
were adopted, it would also provide an authoritative basis for
answering the overly-debated question: "Can a program containing
feature X still be considered a C program?".
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
sizeof((type)) is a constraint violation? Noob C Programming 4 03-08-2012 06:15 AM
Re-using a simple type definition; with enumeration constraint andwithout enumeration constraint puvit82 XML 4 02-01-2008 03:46 PM
Loader constraint violation noorlander@gmail.com Java 1 02-01-2008 02:09 PM
A missing include file is a constraint violation. Jonathan de Boyne Pollard C++ 0 07-26-2003 01:59 AM
Re: How to change Read Only Constraint to Read-Write Isaac VHDL 0 07-10-2003 01:43 PM



Advertisments