"Don't find fault, find a remedy."
Henry Ford (1863-1947); US auto manufacturer.
Introduction
These is the list of defects that I found while writing code in Borland C++
Builder - Professional Edition - version 5.
This section is presented so that people can neutralize the bugs
if they found them.
Definition of Code Defect
Incorrect behaviour
Expected behaviour
Undefined behaviour
Defective Code and non-compliant code
Defects List
1- Defect on the third argument of the event handler for the
OnDrawItem event
1- Defect on the third argument of the event handler for the OnDrawItem event
2- Defect on the second argument of the event handler for the OnContextPopup
event.
Copyright © 1997-2002 Rodolfo A. Frino. All rights reserved.
I also look forward to seeing these bugs fixed in future versions of Builder.
This is my definition of code defect or software bug:
"Code that produces an incorrect, unexpected or undefined result or behaviour"
A code defect exists if a program goes into an infinite loop under some input
values (This defect is also known as Halting bug or Halting problem)
A program has also got a defect when an expected feature is missing. For example,
let's assume that the user wants to save a file with the
Save File option. But when he clicks that option the file is not saved.
Obviously, the program has a bug, since the user expects the Save File feature
to work because it is reasonable to be able to save the contents of a file
(and because the Save File submenu is there)
array[i] = i++;
It could be equivalent to either this:
array[i] = i;
i++;
or to this:
array[i+1] = i;
i++;
depending on compiler settings.
The problem with code that exhibits an undefined behaviour is that the behaviour
is often what you expected, which makes it difficult to detect, specially if you
don't get any compiler warnings.
The concepts of non-portable code and defective code are totally different.
The Standard has confused many people in making them to believe that
non-portability means error.
2- Defect on the second argument of the event handler for the
OnContextPopup event.
This defect affects the third argument of the event handler
corresponding to the OnDrawItem event for both TListBox and TComboBox.
The defect appears when RAD (auto-generated code) writes the handlers at design time only.
Affected code: VCL
Remedy: This defect can be neutralized by the applications programmer
by adding const in both, the function definition and in its declaration.
1a) List Box
Event Handler for the OnDrawItem Event
(To be able to execute this handler add the following line: ListBox1->Style
=lbOwnerDrawVariable; to the code where the List Box is created.)
Affected Code:
void __fastcall TForm1::ListBox1DrawItem( TWinControl *Control,
int Index,
TRect& Rect,
TOwnerDrawState State)
{
}
Affected Code With Correction
Use this code to be able to compile
void __fastcall TForm1::ListBox1DrawItem( TWinControl *Control,
int Index,
const TRect& Rect, <<< Correction
TOwnerDrawState State)
{
}
1b) Combo Box
Event Handler for the OnDrawItem Event.
(To be able to execute this handler add the following line:
ComboBox1->Style = csOwnerDrawVariable; to the code where you create the combo
box.)
Affected Code
void __fastcall TForm1::ComboBox1DrawItem( TWinControl *Control,
int Index,
TRect &Rect,
TOwnerDrawState State )
{
}
Affected Code With Correction
Use this code to be able to compile
void __fastcall TForm1::ComboBox1DrawItem( TWinControl *Control,
int Index,
const TRect &Rect, <<< Correction
TOwnerDrawState State )
{
}
This defect affects the second argument of the event handler
corresponding to the OnContextPopup event for
TButton, TBitBtn, TScrollBox, TreeView, TListView, TRichEdit,TListBox,
TComboBox, etc.
The defect appears when RAD (auto-generated code only) writes the handlers
at design time only.
Affected code: VCL
Remedy: This defect can be neutralized by the applications programmer
by adding const to the second argument in both the function definition and in its
declaration.
Example:
Without correction
void __fastcall TForm1::RichEdit1ContextPopup(TObject *Sender,
TPoint &MousePos, bool &Handled)
{
}
With correction
void __fastcall TForm1::RichEdit1ContextPopup(TObject *Sender,
const TPoint &MousePos, bool &Handled)
{
}
Despite these minor bugs, I consider Borland's C++ Builder
the most advenced compiler in the market today.