From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID, WEIRD_PORT autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 1014db,9adfbb907494972e X-Google-Attributes: gid1014db,public X-Google-Thread: 103376,9adfbb907494972e X-Google-Attributes: gid103376,public From: Tanmoy Bhattacharya Subject: Re: Ada to C/C++ translator needed Date: 1996/10/07 Message-ID: #1/1 X-Deja-AN: 187332181 references: <32499FA0.4B5E@magic.fr> <52feul$os2@goanna.cs.rmit.edu.au> organization: Los Alamos National Laboratory newsgroups: comp.lang.c,comp.lang.ada Date: 1996-10-07T00:00:00+00:00 List-Id: fred@genesis.demon.co.uk (Lawrence Kirby) writes: > > In article > tanmoy@qcd.lanl.gov "Tanmoy Bhattacharya" writes: > > >Not quite. It is still not allowed to violate constraints (This came > >up in the discussion about `char a[1?1:(0,0)]' or some such > >meaningless example in comp.std.c). j++ in a constant expression is a > >violation of a constraint and must be diagnosed. > > I'm sure you're right but which constraint does it violate? > 6.4 Constraint: "Constant expressions shall not contain assignment, increment, decrement, function-call, or comma operators, except when they are contained within the operand of a sizeof operator. Each constant expression shall evaluate to a constant that is in the range of representable values of its type." Note that it does not forbid use of contents of objects (that is in the semantics section), but it does forbid operators that change the values of objects, operators that invoke separate body of code, and the comma operator. Incidentally, assignment operators include (6.3.16) both the simple assignment operator =, and also the compound forms like += etc.; and hence all of these are forbidden. The semantics section forbids a lot more (e.g. using floating point arithmetic if the final answer is integral, using pointers except within sizeof if the final answer is arithmetic, accessing the value of an object etc.) Cheers Tanmoy -- tanmoy@qcd.lanl.gov(128.165.23.46) DECNET: BETA::"tanmoy@lanl.gov"(1.218=1242) Tanmoy Bhattacharya O:T-8(MS B285)LANL,NM87545 H:#9,3000,Trinity Drive,NM87544 Others see , or. -- fax: 1 (505) 665 3003 voice: 1 (505) 665 4733 [ Home: 1 (505) 662 5596 ]