Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > C++ development environment suggestions

Reply
Thread Tools

C++ development environment suggestions

 
 
IR
Guest
Posts: n/a
 
      01-13-2007
Grizlyk wrote:

> IR wrote:
>
>> BCC 5.5

>
> Free BCC 5.5.1 command line tools does not support last C++
> standard (at least my copies).


FWIW, neither does the paying C++Builder 6.
My point, though, was not about standard conformance, but rather
about the fact that _all_ Borland compilers I have worked with
(namely, BC4/4.5, BCB4/5/6, and BCC5.5) are buggy like hell, even
when fully patched.

>> I recently had headaches on a simple ( ? : ) statement which did
>> not behave as expected, until I made it an if-else. This is just
>> one of many examples I could tell.

>
> In most cases you can try find out command line keys, switching
> Borland/Microsoft extentions of C++.


Sorry, but we won't change that kind of compiler settings on a
project which is already about 300kloc, and counting.

> What is the trouble with ( ? : ) statement there?


This very case is indeed a strange BCB6 bug.
I don't have the code at hand, but it was something very
straightforward:


AnsiString __fastcall SomeNetworkMessage::getMessage() const
{
AnsiString msg;
//...
msg = msg + (bool_expression ? "a string" : "another string");
//...
return msg;
}


The "msg = msg + ..." line always added garbage to msg, no matter
the value of bool_expression.

Switching to


if (bool_expression)
msg = msg + "a string";
else
msg = msg + "another string";


solved the bug. Note that in other places, ?: works perfectly fine.

Debugging at asm level showed that both "a string" and "another
string" where in fact taken from the stack (hence the garbage) in
the ?: version, while the if-else version correctly points at the
data segment.


> IR wrote:
>> This is just one of many examples I could tell.

[...]
>> I'm tired of all those strange compilation/linking
>> problems...



Cheers,
--
IR
 
Reply With Quote
 
 
 
 
Sylvester Hesp
Guest
Posts: n/a
 
      01-14-2007

"IR" <> wrote in message
news:Xns98B76EC5112BCZjx3HdoP0Qwt@194.177.96.26...
>> What is the trouble with ( ? : ) statement there?

>
> This very case is indeed a strange BCB6 bug.
> I don't have the code at hand, but it was something very
> straightforward:
>
> [some examples]


That's harsh. On VC++ (all versions AFAIK) I also had issues with the ?: in
combination when used with references.

#include <iostream>

struct A
{
virtual void foo() { std::cout << "A::foo()" << std::endl; }
};

struct B : public A
{
virtual void foo() { std::cout << "B::foo()" << std::endl; }
};

int main()
{
A a;
B b;
A & aRef = false ? a : b;
aRef.foo();
}

Guess what above program outputs. Right, A::foo(), because a temporary A is
copy-constructed out of a B, and tied to the reference (which shouldn't even
be possible according to the standard, as the reference is not const, but
VC++ allows it when language extensions are enabled). It took me some time
to find out why my data appeared to corrupt.

I fixed it by explicitely static_casting 'b' to an A&. So apparently the
compiler prefers value over reference when the two opererands are not of the
same type. "Luckily" this is only a mere misinterpretation of the standard,
it isn't as severe as wrong assembly code actually being generated (like in
your example)

- Sylvester


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
70-284 Lab Environment, Need Virtual Environment brooklynbridge508@hotmail.com MCSA 4 05-02-2007 09:49 AM
Setting an environment variable from another environment variable marcwentink@hotmail.com Java 5 04-04-2007 10:39 PM
Developing Web Service in VS2005 on Win2003 Server: Need environment suggestions sinisa.stokic@gmail.com ASP .Net 1 02-20-2006 08:16 PM
development environment architecture for ASP.NET development team Akhlaq Khan ASP .Net 4 09-27-2004 01:33 PM
Suggestions for setting up test and live development environment on the same computer JerryK ASP .Net 2 01-29-2004 04:11 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57