🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c
Article #4093

Re: Erroneous diagnostic from VOS 'C' compiler?

#4093
From: Ian Cargill
Date: Sat, 23 Sep 1995 08:29
39 lines
1767 bytes
In article <DFBq4o.FED@polo.demon.co.uk> john@polo.demon.co.uk writes:

>The VOS (Stratus) 'C' compiler generates an error on encountering
>the following code and refuses to compile it, complaining that the
>curly brackets are superfluous.  Is it broken?
>
>int an_array [1] = {1} ;
>
>John
>P.S.  It is perfectly happy with :
>
>int another_array [2] = {1, 2} ;
>

Yes, it's broken.  As I read the standard, it is an error if it 
_were not_ brace enclosed.  The semantics of 6.5.7 say:

# Otherwise, the initialiser for an object that has aggregate type 
# shall be a brace-enclosed list of initialisers...

Looking at the 'otherwise' cases, I can't see anything which allows 

  int an_array [1] = 1 ;

So your compiler seems not only to be rejecting something which is 
valid, it is _requiring_ something which is invalid!

(I am pretty sure I am correct in saying that _any_ initialiser can 
be brace-enclosed, even for scalars and strings. i.e. 

int x = {1};
char *cp={"hello"};

I can't think of an exception off-hand.

-- 
============================================================================
 Ian Cargill  CEng MIEE  | Find out about the Association of C and C++ Users
 Soliton Software Ltd.   | info@accu.org OR  http://bach.cis.temple.edu/accu
Technical Details
Message-ID: <811844986snz@soliton.demon.co.uk>
Path: arc1-ca.pugleaf.net!mail2news.demon.co.uk!soliton.demon.co.uk
References: <DFBq4o.FED@polo.demon.co.uk>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!mail2news.demon.co.uk!soliton.demon.co.uk
From: Ian Cargill <ian@soliton.demon.co.uk>
Newsgroups: comp.std.c
Subject: Re: Erroneous diagnostic from VOS 'C' compiler? 
Date: Sat, 23 Sep 95 08:29:46 GMT
Organization: Soliton Software Ltd.
Message-ID: <811844986snz@soliton.demon.co.uk>
References: <DFBq4o.FED@polo.demon.co.uk>
Reply-To: ian@soliton.demon.co.uk
X-NNTP-Posting-Host: soliton.demon.co.uk
X-Newsreader: Simple NEWS 2.0 (ka9q DIS 1.24)