Topic: Re[2]: ++var


Author: clamage@eng.sun.com (Steve Clamage)
Date: 1999/09/20
Raw View
Roman Belenov <roman@nstl.nnov.ru> writes:

>SC> But that expectation is not justified. "Undefined behavior" means
>SC> the standard places NO requirements on the implementation. Any
>SC> result, including "-1", "42", a refusal to compile, or a run-time
>                                  ^^^^^^^^^^^^^^^^^^^^
>SC> abort, is allowed.

>IMHO  this  particular  behaviour  is  not standard - the code must be
>compiled, ...

Section 1.3.12 of the C++ standard says that compilation can be
terminated in the case of undefined behavior.

--
Steve Clamage, stephen.clamage@sun.com
---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html              ]





Author: James.Kanze@dresdner-bank.com
Date: 1999/09/21
Raw View
In article <7s5o22$ikm$1@engnews1.eng.sun.com>,
  clamage@eng.sun.com (Steve Clamage) wrote:
> Roman Belenov <roman@nstl.nnov.ru> writes:
>
> >SC> But that expectation is not justified. "Undefined behavior" means
> >SC> the standard places NO requirements on the implementation. Any
> >SC> result, including "-1", "42", a refusal to compile, or a run-time
> >                                  ^^^^^^^^^^^^^^^^^^^^
> >SC> abort, is allowed.

> >IMHO  this  particular  behaviour  is  not standard - the code must
be
> >compiled, ...

> Section 1.3.12 of the C++ standard says that compilation can be
> terminated in the case of undefined behavior.

Do you mean 1.4.12, or did the numbering change here between the FDIS
that I use and the final standard?

Anyway, I believe that the actual undefined behavior in this case is
modifying the same variable without an intervening sequence point.  The
code in question will only do this if it is actually executed, so the
compiler should only be able to terminate compilation if it can prove
that the code in question *is* actually executed, or ?

--
James Kanze                   mailto: James.Kanze@dresdner-bank.com
Conseils en informatique orient   e objet/
                  Beratung in objekt orientierter Datenverarbeitung
Ziegelh   ttenweg 17a, 60598 Frankfurt, Germany Tel. +49(069)63198627


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html              ]





Author: Roman Belenov <roman@nstl.nnov.ru>
Date: 1999/09/20
Raw View
Hello Steve,

SC> But that expectation is not justified. "Undefined behavior" means
SC> the standard places NO requirements on the implementation. Any
SC> result, including "-1", "42", a refusal to compile, or a run-time
                                  ^^^^^^^^^^^^^^^^^^^^
SC> abort, is allowed.

IMHO  this  particular  behaviour  is  not standard - the code must be
compiled, even though the resulting binary may destroy the Earth.


Best regards,
 Roman                            mailto:roman@nstl.nnov.ru




 Sent via Deja.com http://www.deja.com/
 Share what you know. Learn what you don't.


[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html              ]