[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#348117: g++-4.0: g++ upgrade broke ncurses c++ demo



Package: g++-4.0
Version: 4.0.2-5
Severity: important


Retesting ncurses c++ demo, I get an exception in code which hasn't
changed for several months and which has no apparent error (checked
with valgrind).  This function

void TestApplication::init_labels(Soft_Label_Key_Set& S) const
{ 
  for(int i=1; i <= S.labels(); i++) {
    char buf[5];
    ::sprintf(buf,"Key%02d",i);
    S[i] = buf;                                      // Text 
    S[i] = Soft_Label_Key_Set::Soft_Label_Key::Left; // Justification 
  }
}

is raising an exception in the [] operator for S, which claims that
the index i is zero.  So it dies on the "Text" line.  The buf variable
contains "Key01", so the index was correct on the previous line.
valgrind can only tell me that the program raised an exception -
which is not the cause of the problem in this case.  Here's what
gdb shows me:

(gdb) break demo.cc:504
Breakpoint 1 at 0x804b724: file ../c++/demo.cc, line 504.
(gdb) run
Starting program: /usr/build/ncurses/ncurses-5.5-20060114/c++/demo

Breakpoint 1, TestApplication::init_labels (this=0x805cdac, S=@0x805cec0)
    at ../c++/demo.cc:504
504         ::sprintf(buf,"Key%02d",i);
(gdb) print i
$1 = 1
(gdb) next
505         S[i] = buf;                                      // Text
(gdb) print i
$2 = 0
(gdb) 

I checked this against ncurses 5.5, just in case there was some
recent change of mine that I should debug - it has the same
problem.

-- System Information:
Debian Release: testing/unstable
  APT prefers testing
  APT policy: (500, 'testing')
Architecture: i386 (i686)
Shell:  /bin/sh linked to /bin/bash
Kernel: Linux 2.4.27-td2
Locale: LANG=C, LC_CTYPE=C (charmap=ANSI_X3.4-1968)

Versions of packages g++-4.0 depends on:
ii  gcc-4.0                       4.0.2-5    The GNU C compiler
ii  gcc-4.0-base                  4.0.2-5    The GNU Compiler Collection (base 
ii  libc6                         2.3.5-8    GNU C Library: Shared libraries an
ii  libstdc++6-4.0-dev            4.0.2-5    The GNU Standard C++ Library v3 (d

g++-4.0 recommends no packages.

-- no debconf information



Reply to: