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, MSGID_RANDY autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,ca9eef4d5e2078ea X-Google-Attributes: gid103376,public From: Rakesh Malhotra Subject: Re: Beware: Rep spec on an enumeration type causes code explosion Date: 1997/12/12 Message-ID: <66s5k1$f1t$1@gte2.gte.net>#1/1 X-Deja-AN: 297638238 References: <66po35$1a1$1@gte2.gte.net> X-Priority: 3 (Normal) Organization: gte.net X-Auth: UNKNOWN@207.175.180.7 Newsgroups: comp.lang.ada Date: 1997-12-12T00:00:00+00:00 List-Id: Matthew Heaney wrote: > > In article <66po35$1a1$1@gte2.gte.net>, Rakesh Malhotra > wrote: > >[snip] > > > >Hence type SIGNAL_TYPE is (RED, GREEN); > >for SIGNAL_TYPE use (RED => 16#00#, GREEN => 16#03#); > >[snip] > >Pretty horrible eh ? > > This is a seriously wrong way to build safety-critical software. As a > matter of fact, it's a wrong way to build *any* software. You are quite > correct in pointing out that it is "pretty horrible." It may be a wrong way of building safe software but it (seems to be ?) is not uncommon. I know of and have worked in 3 different companies in 3 different countries who have chosen to implement their enumeration types this way. And successfully. 1 project was in Pascal and 3 in Ada and all did it the same way for enum types. Just as an aside safety can be implemented on a project in many different ways. One of the best ways is to implement safety as high up in the system as possible - so maybe one chooses a diverse or redundant design. However this tends to be expensive as one duplicates hardware. So for cost reasons we had to implement safety at a fairly low level and one of the areas is consideration of what would happen if an alpha particle from the sun hit the RAM chip and corrupted your signal state from RED to GREEN due to a 1 bit corruption. Would you now turn your signal GREEN ? Obviously bit separation of enums is not the only thing we do, however it is one of the tools in our cupboard. -- Rakesh