🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c
Article #302

Legal forms of constant expressions in initializers

#302
From: J. Stephen Adamczyk
Date: Fri, 07 Jul 1989 16:22
19 lines
816 bytes
By my reading of section 3.4, both of the following examples are
not legal:

/* 1 */
static int i = "abc"[2];

/* 2 */
static int a[5];
static int j = &a[3] - &a[2];

The second example, in particular, is interesting, since by my reading
K&R (first edition) allows it, and the pcc-based compiler on my Sun does
too.

Anyone feel these are legal?  Have I read the text wrong?

Steve Adamczyk
uunet!edg1!jsa
(201) 769-8262
Technical Details
Message-ID: <339@edg1.UUCP>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!cs.utexas.edu!uunet!edg1!jsa

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!cs.utexas.edu!uunet!edg1!jsa
From: jsa@edg1.UUCP (J. Stephen Adamczyk)
Newsgroups: comp.std.c
Subject: Legal forms of constant expressions in initializers
Keywords: constant-expression initializer
Message-ID: <339@edg1.UUCP>
Date: 7 Jul 89 16:22:01 GMT
Organization: Edison Design Group, Inc., Edison, NJ
Lines: 19