c++.stl.port - error with DbC
-
FUKUDA, Fumiki
(31/31)
Oct 06 2004
#include
- FUKUDA, Fumiki (1/1) Oct 07 2004 oops... sorry, dumpilated.
- Alan (7/20) Dec 26 2004 Putting function half in the stream causes 'undefined behaviour'
#include <iostream> #include <cassert> int half(int n) __in { assert( n > 0 ); } __out (result) { assert(result+result < n); } __body { return n/2; } int main() { std::cout << "Hello, world" << half(-5) << std::endl; return 0; } this code reports compile error under DMC841C+STLport even if '-D' is NOT specified. why? what should I do? __in { assert( n > 0 ); } ^ foo.cpp(5) : Error: '__stl_in' is not in function par __out (result) { assert(result+result < n); } ^ foo.cpp(6) : Error: '=', ';' or ',' expected } ^ foo.cpp(10) : Error: '=', ';' or ',' expected return 0; ^ foo.cpp(14) : Error: '=', ';' or ',' expected } ^ foo.cpp(15) : Error: '=', ';' or ',' expected Fatal error: too many errors
Oct 06 2004
<FUKUDA>; "Fumiki" <FUKUDA,_member pathlink.com> wrote in message news:ck2pa8$s1t$1 digitaldaemon.com...#include <iostream> #include <cassert> int half(int n) __in { assert( n > 0 ); } __out (result) { assert(result+result < n); } __body { return n/2; } int main() { std::cout << "Hello, world" << half(-5) << std::endl; return 0; }Putting function half in the stream causes 'undefined behaviour' (UB), better : int main { int result = half(-5); std::cout << "result = " << result << "\n": }
Dec 26 2004