Re: int pointing to char

From: Dan Pop (Dan.Pop_at_cern.ch)
Date: 03/10/04


Date: 10 Mar 2004 15:23:01 GMT

In <slrnc4tnrg.4mn.jeremy@maka.cl.cam.ac.uk> Jeremy Yallop <jeremy@jdyallop.freeserve.co.uk> writes:

>James Hu wrote:
>> However, I honestly believe that applying semantics to code that has
>> constraint violations is enough to determine if the code is erroneous
>> or not. The constraint violation alone does not have render the
>> code erroneous.
>
>This is a mistake. The language clauses of the standard are arranged
>into syntax/constraints/semantics groupings. The order is relevant:
>the meaning is "code with this syntax, subject to these constraints,
>has these semantics". If the syntax does not match then the
>constraints are irrelevant. If the syntax matches but the constraints
>are not satisfied then the semantics don't apply to the code.

It's interesting to note that, in order to avoid baroque syntax
specifications, many constraints are actually completing the syntax
rules: if it was too difficult to put it in a formal way in a syntax
specification, it was put into plain English in a subsequent constraint.

A funny case is:

     6.5.2.1 Array subscripting

     Constraints

1 One of the expressions shall have type ``pointer to object type'',
     the other expression shall have integer type, and the result
     has type ``type''.

The first part is really dealing with syntax and the last part is pure
semantics.

Dan

-- 
Dan Pop
DESY Zeuthen, RZ group
Email: Dan.Pop@ifh.de


Relevant Pages

  • Re: macro preprocessor semantics and the ANSI standard
    ... 'constraints' are not part of the syntax, but part of the semantics ... They are part of the syntax, but it's easier to impose them as ... Unsolicited bulk E-mail subject to legal action. ...
    (comp.lang.pl1)
  • Pythonification of the asterisk-based collection packing/unpacking syntax
    ... packing and unpacking syntax. ... In case the asterisk is not used to signal unpacking, ... type constraints throughout python as a whole; ...
    (comp.lang.python)
  • Re: "semantic" in n1336.pdf
    ... of language elements is to be interpreted ... checkable at compile time but goes slightly beyond the syntax. ... All constraints are checkable (and must be checked, ... "the semantics of + is to produce the sum of its operands". ...
    (comp.lang.c)
  • Re: subroutine stack and C machine model
    ... You stated elsewhere that constant expressions are a ... section so presumably you include in "syntax" the constraints whilst ... Rather, I believe that, if you follow the syntax down far ... support such a rigid distinction. ...
    (comp.lang.c)
  • Re: Implicit Declaration
    ... constraint violation or a syntax violation ... The standard certainly treats them differently, putting syntax rules ... places constraints in sections named "Constraints". ...
    (comp.lang.c)