Bug 244029 - build fails - variable size array in perl/qtcore/src/util.cpp
Summary: build fails - variable size array in perl/qtcore/src/util.cpp
Status: RESOLVED FIXED
Alias: None
Product: bindings
Classification: Developer tools
Component: general (show other bugs)
Version: unspecified
Platform: Compiled Sources Solaris
: NOR normal
Target Milestone: ---
Assignee: kde-bindings
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-07-09 12:53 UTC by tropikhajma
Modified: 2010-08-04 02:58 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
Create variable size array on the heap (526 bytes, patch)
2010-07-21 23:11 UTC, Chris Burel
Details
Create variable size array on the heap (526 bytes, patch)
2010-07-21 23:16 UTC, Chris Burel
Details

Note You need to log in before you can comment on or make changes to this bug.
Description tropikhajma 2010-07-09 12:53:49 UTC
Version:           unspecified (using Devel) 
OS:                Solaris

building kdebindings 4.4.92 fails with the below message.
This is because variable size arrays are not part of the C++ standard and the Sun Studio compiler does not support them. AFAIK MSVC does not support them either.

I do not have a patch ATM, but generally people recommend using vector instead.

test@continuousbuild:~/packages/BUILD/kdebindings-4.4.92/build-kdebindings-4.4.92/perl/qtcore/src$ cd /export/home/test/packages/BUILD/kdebindings-4.4.92/build-kdebindings-4.4.92/perl/qtcore/src && /opt/sunstudio12.1/bin/CC  -library=no%Cstd -library=Crun  -Dperlqtcore4_EXPORTS -DQT_NO_STL -DQT_NO_CAST_TO_ASCII -D_REENTRANT -DKDE_DEPRECATED_WARNINGS -DQT3_SUPPORT -DDEBUG -DDEBUG -D__EXTENSIONS__ -DSOLARIS -D_REENTRANT -DNDEBUG -D__EXTENSIONS__ -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -D_POSIX_PTHREAD_SEMANTICS -DSOLARIS -DSOLARIS10 -DNO_DEBUG -D_UNICODE -DUNICODE -D_RWSTD_REENTRANT  -D_XOPEN_SOURCE=500 -D_XPG5  -I/usr/include/stdcxx4/ansi -I/usr/include/stdcxx4 -I/opt/kde4/include -I/opt/kde4/include/boost-1_43 -DHAS_BOOL -I/usr/include/stdcxx4/ansi -I/usr/include/stdcxx4 -library=no%Cstd -library=Crun -features=anachronisms,except,rtti,export,extensions,nestedaccess,tmplife,tmplrefstatic -instances=global -template=geninlinefuncs -s -xdebugformat=dwarf -xlang=c99 -xalias_level=compatible -xustr=ascii_utf16_ushort -Qoption ccfe -features=gcc -Qoption ccfe -features=zla -Qoption ccfe ++boolflag:sunwcch=false -mt -xF=%none -xbuiltin=%all -xinline=%auto -xprefetch=auto -xprefetch_auto_type=indirect_array_access -xprefetch_level=3 -xalias_level=compatible -KPIC -DPIC -xipo=0 -xO3 -xregs=no%frameptr -xjobs=2 -xrestrict=%all -xthreadvar=%all -z combreloc -z redlocsym -z nodefaultlib -z ignore -z now -z rescan -z absexec -xldscope=symbolic -xlibmil -s -xtarget=pentium4 -m32 -xarch=sse2 -xchip=pentium4 -xcache=8/64/4:256/128/8 -lc -lm -ldl -lpthread -lposix4 -lrt -mt -L/opt/kde4/lib -R/opt/kde4/lib -L/usr/lib -R/usr/lib -Y P,/opt/kde4/lib -i -L/opt/kde4/lib -R/opt/kde4/lib -L/usr/lib -R/usr/lib -Bdynamic -lstdcxx4 -lCrun -lc -lm   -DQT_NO_DEBUG -KPIC -I/export/home/test/packages/BUILD/kdebindings-4.4.92/build-kdebindings-4.4.92/perl/qtcore/src -I/export/home/test/packages/BUILD/kdebindings-4.4.92/perl/qtcore/src -I/export/home/test/packages/BUILD/kdebindings-4.4.92 -I/export/home/test/packages/BUILD/kdebindings-4.4.92/build-kdebindings-4.4.92 -I/export/home/test/packages/BUILD/kdebindings-4.4.92/smoke -I/opt/kde4/include -I/opt/kde4/include/KDE -I/opt/kde4/include/QtXmlPatterns -I/opt/kde4/include/QtXml -I/opt/kde4/include/QtWebKit -I/opt/kde4/include/QtUiTools -I/opt/kde4/include/QtTest -I/opt/kde4/include/QtSvg -I/opt/kde4/include/QtSql -I/opt/kde4/include/QtScriptTools -I/opt/kde4/include/QtScript -I/opt/kde4/include/QtOpenGL -I/opt/kde4/include/QtNetwork -I/opt/kde4/include/QtMultimedia -I/opt/kde4/include/QtHelp -I/opt/kde4/include/QtDesigner -I/opt/kde4/include/QtDBus -I/opt/kde4/include/QtAssistant -I/opt/kde4/include/Qt3Support -I/opt/kde4/include/QtGui -I/opt/kde4/include/QtCore -I/opt/kde4/include/Qt -I/opt/kde4/share/mkspecs/default -I/usr/X11/include -I/usr/perl5/5.8.4/lib/i86pc-solaris-64int/CORE    -D_LARGEFILE64_SOURCE -o CMakeFiles/perlqtcore4.dir/util.o -c /export/home/test/packages/BUILD/kdebindings-4.4.92/perl/qtcore/src/util.cpp
"/export/home/test/packages/BUILD/kdebindings-4.4.92/perl/qtcore/src/smokeperl.h", line 52: Warning: Identifier expected instead of "}".
"/export/home/test/packages/BUILD/kdebindings-4.4.92/perl/qtcore/src/util.cpp", line 429: Error: An integer constant expression is required within the array subscript operator.

Reproducible: Always
Comment 1 Chris Burel 2010-07-21 23:11:13 UTC
Created attachment 49371 [details]
Create variable size array on the heap

I looked through the rest of the source, and this is the only location I see that doesn't use new[] to make a variable sized array.
Comment 2 Chris Burel 2010-07-21 23:13:26 UTC
Comment on attachment 49371 [details]
Create variable size array on the heap

--- kdebindings-4.4.92/perl/qtcore/src/util.cpp	2010-06-24 09:31:32.000000000 -0700
+++ kdebindings/perl/qtcore/src/util.cpp	2010-07-21 14:03:12.383019515 -0700
@@ -426,10 +426,9 @@
     }
 
     // Get the ISA array, nisa is a temp string to build package::ISA
-    char nisa[strlen(package)+6];
+    char *nisa = new char[strlen(package)+6];
     sprintf( nisa, "%s::ISA", package );
     AV* isa = get_av( nisa, true );
+    delete[] nisa;
 
     // Loop over the ISA array
     for( int i = 0; i <= av_len( isa ); i++ ) {
Comment 3 Chris Burel 2010-07-21 23:16:17 UTC
Comment on attachment 49371 [details]
Create variable size array on the heap

This patch is reversed.
Comment 4 Chris Burel 2010-07-21 23:16:56 UTC
Created attachment 49373 [details]
Create variable size array on the heap
Comment 5 tropikhajma 2010-07-22 14:59:12 UTC
confirming the patch helped
Comment 6 Chris Burel 2010-08-04 02:58:24 UTC
This patch was applied in revision 1155137.