c++ - value of a condition
- Christof Meerwald (33/33) Jan 10 2002 Hi,
- Walter (5/38) Jan 10 2002 Ok, I'll get it fixed. Thanks for the great bug reports! -Walter
Hi, According to the C++ standard (6.4 Selection statements [stmt.select]) "the value of a condition that is an expression is the value of the expression, implicitly converted to bool for statements other than switch". But it seems that DM uses the value of the expression implicitly converted to int (the following test-case prints "false"): #include <stdio.h> struct A { inline operator int() { return 0; } inline operator bool() { return true; } }; int main(int argc, char *argv[]) { A a; if (a) { printf("true\n"); return 0; } else { printf("false\n"); return 1; } } bye, Christof
Jan 10 2002
Ok, I'll get it fixed. Thanks for the great bug reports! -Walter "Christof Meerwald" <cmeerw web.de> wrote in message news:a1k5q7$2v33$1 digitaldaemon.com...Hi, According to the C++ standard (6.4 Selection statements [stmt.select])"thevalue of a condition that is an expression is the value of the expression, implicitly converted to bool for statements other than switch". But itseemsthat DM uses the value of the expression implicitly converted to int (the following test-case prints "false"): #include <stdio.h> struct A { inline operator int() { return 0; } inline operator bool() { return true; } }; int main(int argc, char *argv[]) { A a; if (a) { printf("true\n"); return 0; } else { printf("false\n"); return 1; } } bye, Christof
Jan 10 2002