#9 ISO C++ forbids variable-size array `old'

closed-fixed
nobody
None
5
2004-07-01
2004-06-30
Anonymous
No

version 0.42 on gentoo linux last everything (kernel
2.6.7...)

I typed ./configure ... worked fine
I typed make and got

......
OInfoASCII.cpp:217: warning: `char cprev' might be used
uninitialized in this
function
IOInfoASCII.cpp: In member function `virtual
QPtrList<IOInfo>
IOInfoASCII::getSingles()':
IOInfoASCII.cpp:524: warning: `char cprev' might be
used uninitialized in this
function
if g++ -DHAVE_CONFIG_H -I. -I. -I.. -I/usr/qt/3/include
-I/usr/X11R6/include -DQT_THREAD_SUPPORT -D_REENTRANT
-g -Wnon-virtual-dtor -Wno-long-long -Wundef -Wall
-pedantic -W -Wpointer-arith -Wwrite-strings -ansi
-D_XOPEN_SOURCE=500 -D_BSD_SOURCE -Wcast-align
-Wconversion -O2 -fno-exceptions -fno-check-new -MT
IOInfoBin.o -MD -MP -MF ".deps/IOInfoBin.Tpo" \ -c -o IOInfoBin.o `test -f 'IOInfoBin.cpp' || echo
'./'`IOInfoBin.cpp; \ then mv -f ".deps/IOInfoBin.Tpo" ".deps/IOInfoBin.Po"; \ else rm -f ".deps/IOInfoBin.Tpo"; exit 1; \ fi
IOInfoBin.cpp: In member function `virtual void
IOInfoBin::setSize(int)':
IOInfoBin.cpp:231: error: ISO C++ forbids variable-size
array `old'
make[2]: *** [IOInfoBin.o] Error 1
make[2]: Leaving directory
`/home/louis/temporary/qfsm-0.42/src'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory
`/home/louis/temporary/qfsm-0.42'
make: *** [all] Error 2

Discussion

  • Nobody/Anonymous

    Logged In: NO

    I added at the top of the file:

    #include <vector>

    and I replaced line 231 by:

    std::vector<char> old;old.resize(oldin+1);//char old[oldin+1];

     
  • Stefan Duffner

    Stefan Duffner - 2004-07-01

    Logged In: YES
    user_id=355503

    Here is a patch that should resolve your problem. If you're not familiar
    with 'diff' and 'patch', just erase the lines preceded by a '-' and add
    those preceded by a '+'.

    --- qfsm-0.42.orig/src/IOInfoBin.cpp
    +++ qfsm-0.42/src/IOInfoBin.cpp
    @@ -228,10 +228,10 @@
    void IOInfoBin::setSize(int newin)
    {
    int oldin = getLength();
    - char old[oldin+1];
    int oldcount;
    - char *pin;
    + char *old, *pin;

    + old = new char[oldin+1];
    pin = getInfo();
    for (int i=0; i<=oldin; i++)
    {
    @@ -254,6 +254,7 @@

    setInfo(pin);

    + delete [] old;
    delete [] pin;

    }

     
  • Stefan Duffner

    Stefan Duffner - 2004-07-01
    • status: open --> closed-fixed
     

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks