comp.lang.ada
 help / color / mirror / Atom feed
From: Biju Thomas <bijuthom@ibm.net>
Subject: Re: Ada or C++ acting 'correctly' here?
Date: 1999/02/27
Date: 1999-02-27T00:00:00+00:00	[thread overview]
Message-ID: <36D85A54.2A0E6283@ibm.net> (raw)
In-Reply-To: 7b9i8l$6ql$1@ash.prod.itd.earthlink.net

Claudius Proculus wrote:
> 
> In article <7b8c7u$sj1@drn.newsguy.com>, bill@mooner wrote:
> >compare these 2 little programs, do same thing, one in C++
> >and one in Ada. The C++ program compiles Ok, but result is
> >negative, the Ada program refused to compile:
> >
> >
> >----------------------------
> >#include <iostream>
> >int main()
> >{
> >  cout<<(500000000*7);
> >  return 0;
> >}
> >-----------------------------
> >%g++ -Wall test_mult.cc
> >%./a.out
> >-794967296
> >
> >(this is g++ 2.8.1)
> >
> 
> They are both the correct behavior.
> 

No. The C++ compiler is non-conforming. The C++ standard says that if a
constant expression cannot be represented in the target type, the
program is ill-formed. (Chapter 5, paragraph 5.) A C++ compiler is
required to issue a diagnostic message while compiling an ill-formed
program. (It is *not* an undefined behaviour.)

> However, this does illustrate one of the benefits of using Ada.
 
Ada certainly will have benefits, but not on this one.

-- 
Best regards,
Biju Thomas




  reply	other threads:[~1999-02-27  0:00 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-02-27  0:00 Ada or C++ acting 'correctly' here? bill
1999-02-27  0:00 ` Steve Doiel
1999-02-27  0:00 ` Florian Weimer
     [not found]   ` <36e8e201.48455851@netnews.worldnet.att.net>
1999-03-18  0:00     ` bglbv
1999-02-27  0:00 ` Claudius Proculus
1999-02-27  0:00   ` Biju Thomas [this message]
1999-02-28  0:00     ` robert_dewar
1999-02-28  0:00       ` Florian Weimer
1999-03-01  0:00         ` dewar
1999-02-27  0:00 ` Gautier.DeMontmollin
1999-02-27  0:00 ` Matthew Heaney
1999-02-28  0:00 ` William McKenzie
1999-03-01  0:00   ` fraser
1999-03-01  0:00   ` Hubert B. Keller
1999-02-28  0:00 ` robert_dewar
1999-03-02  0:00 ` Willliam V
1999-03-02  0:00   ` Pascal Obry
1999-03-02  0:00   ` Gautier.DeMontmollin
1999-03-02  0:00     ` kvisko
1999-03-02  0:00   ` robert_dewar
1999-03-02  0:00   ` SpamSpamSpam
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox