#15 code completion / debugger


A new list of some bugs, in total 3.
To reconstruct use the contents of the attached
complex.rar file. This contains a very small and very
silly project.

Bug 1 (code completion) :
In the main file (main.cpp), there are 3 instaneces of
the complex class made (c1, c2, and c3). At the end of
the main function you can see the line c2.stupid();
well after this line retype that line, but first start
with c1.stupid() and c3.stupid(), when the dot '.' is
typed the code completion kicks in. Yihaa, but when you
try this with c2, the code completion is sleeping and
does not wake up. Could this be by the way the parser
parsed the declaration.
Complex c1;
Complex c2(5);
Complex c3;
For c2, an argument was handed to the constructor,
while for c1 and c3, no arguments -> default
constructor. So maybe the '(5)' confused the parser ???

Bug 2 (code completion) :
The complex class has a static const member (DIM), in
complex.cpp it is also defined (the thing is complex.h
is a declaration, although you can specify an initial
value) (See Remark 1 at the bottom). So while I was
typing the definition line in complex.cpp (at the
bottom of the file) when I pressed '::' no code
completion happening. Although all files had been saved
(so probably reparsed), but maybe this online works
after it had a definition; So, when you start retyping
that last definition line, 'const in Complex::' again
now code completion. So this is certainly a bug. The ::
is necessary sometimes to access the static members of
a class !

Bug 3 (debugger) :
Put a breakpoint at the last line of the main function
and step into the c2.Stupid(). This utterly stupid
function will put 'A's in the m_Array. So at start it
are random byte values. You can see this by adding a
watch to the m_Array. And then by stepping through the
function the A's show up in the watch. Now let the
program finish, and restart the debugger : In the watch
window the A's stay, but this is incorrect. Remove the
watch and add it again, and you will see again the
random bytes, and these are correct. So the watch
window might fool the user by suggesting the correct
values are already in there. So a refresh of the
watched variables needs to be carried out !!!!!
Note this should also happen when you exit a function,
the watched variables whose scope was in that function
(locals) or part of that class and the caller of the
function is another class, because it is well possible
that the calling class also has a variable with the
same name as the the callee class.

Remark 1 :
You can do without the definition in the complex.cpp
file for the static, but then the debugger is not able
to show the value of it, with the definition it is. I
don't know if without the definition the ansi standards
are met, but I guess the compiler is replacing (or
better it's preprocessor) the occurences of the static
by it's value, sort of #define), and in the case with
the definition keeps it as a seperate const variable.
this is purely guessing from my site, gonna investigate
more on this by looking at the assembler code.



  • Lieven de Cock

    Lieven de Cock - 2003-01-12
  • CIBI3D

    CIBI3D - 2004-12-22

    Logged In: YES

    I have another bug with autocompletion and the scopes. I
    have a class:

    class CTriangle {
    enum COORDINATE {

    in a header file. In the same file I have to access that
    enum. If I use the CTriangle::COORDINATE_LOCAL for example,
    the autocompletion shows me all the list, OK!, if I select
    COORDINATE_LOCAL autocompletion writes
    CTriangle:COORDINATE_LOCAL, it's ereasing one ":" :@. I
    wrote a lot of lines with that "little error" and when I
    compiled you can imagine the book that I could make using
    the errors... Well, thanks!


Log in to post a comment.