Re: Constraint violation - when?

Discussion in 'C Programming' started by James Kuyper, Jul 30, 2008.

  1. James Kuyper

    James Kuyper Guest

    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?
     
    James Kuyper, Jul 30, 2008
    #1
    1. Advertising

  2. James Kuyper <> 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.ghoti.net/~kst>
    Nokia
    "We must do something. This is something. Therefore, we must do this."
    -- Antony Jay and Jonathan Lynn, "Yes Minister"
     
    Keith Thompson, Jul 30, 2008
    #2
    1. Advertising

  3. James Kuyper

    Guest

    Keith Thompson wrote:
    > James Kuyper <> 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.
     
    , Jul 30, 2008
    #3
  4. James Kuyper

    Guest

    James Kuyper <> 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
     
    , Aug 13, 2008
    #4
  5. James Kuyper

    Guest

    wrote:
    > James Kuyper <> 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?".
     
    , Aug 13, 2008
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Isaac
    Replies:
    0
    Views:
    2,481
    Isaac
    Jul 10, 2003
  2. Jonathan de Boyne Pollard

    A missing include file is a constraint violation.

    Jonathan de Boyne Pollard, Jul 26, 2003, in forum: C++
    Replies:
    0
    Views:
    355
    Jonathan de Boyne Pollard
    Jul 26, 2003
  3. puvit82
    Replies:
    4
    Views:
    780
    puvit82
    Feb 1, 2008
  4. Replies:
    1
    Views:
    609
  5. Noob
    Replies:
    4
    Views:
    391
    Nils M Holm
    Mar 8, 2012
Loading...

Share This Page