Compile failure (clang): "variable length array" errors in box3d.cpp

Bug #889172 reported by Daniel Macks on 2011-11-11
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Inkscape
Medium
ideasman42

Bug Description

Building inkscape-0.48.0 on OS X 10.7 using clang from XCode4.2 fails:

box3d.cpp:463:25: error: variable length array of non-POD element type 'Geom::Point'
    Geom::Point snap_pts[num_snap_lines];

The code is one of several places in that source file with the following pattern:
    int num_snap_lines = (id != -1) ? 3 : 4;
    Geom::Point snap_pts[num_snap_lines];
where id is a parameter passed to the function that contains this code. Sure enough, variable-length arrays are part of the c99 standard but not part of the c++ standard (though gcc seems to allow it). I don't know how widespread this use is in inkscape, but for box3d.cpp, it appears it's just used for creating some local variables within box3d_snap(), so it would probably suffice to hardcode the arrays to be the largest possibly-needed size (and then just not use all the elements in some cases).

su_v (suv-lp) on 2011-11-11
tags: added: build
su_v (suv-lp) wrote :

<off-topic>
> Building inkscape-0.48.0 on (…)

Unrelated to which compiler is used and whether Inkscape compiles on any platform with clang - any reason not to use the latest bug-fix release 0.48.2?
</off-topic>

> (…) on OS X 10.7 using clang from XCode4.2 fails

AFAIK the Portfile for Inkscape in Mac Ports does force the usage of 'llvm-gcc-4.2' on Lion [2] for now.

Related discussions on the mailing list about building Inkscape [1] with clang:
<http://thread.gmane.org/gmane.comp.graphics.inkscape.devel/36760>
<http://thread.gmane.org/gmane.comp.graphics.inkscape.devel/37024>

[1] probably Inkscape trunk, not the stable release branch
[2] <https://trac.macports.org/browser/trunk/dports/graphics/inkscape/Portfile#L87>

su_v (suv-lp) wrote :

Fixes already committed in Inkscape trunk to allow building with clang:
 <http://bazaar.launchpad.net/~inkscape.dev/inkscape/trunk/revision/10398>
 <http://bazaar.launchpad.net/~inkscape.dev/inkscape/trunk/revision/10399>

Possibly there are later ones (I did not search the commit logs in detail).
These changes have not been backported to the stable branch (0.48.x).

su_v (suv-lp) wrote :

Setting status to 'Committed' since the reported error in 'src/box3d.cpp' has been addressed in trunk.
Adding tag 'backport-proposed' (needs to be investigated).

Please reopen if you think the report was closed in error.

summary: - Compile failure: "variable length array" errors in box3d.cpp
+ Compile failure (clang): "variable length array" errors in box3d.cpp
Changed in inkscape:
assignee: nobody → ideasman42 (ideasman42)
milestone: none → 0.49
status: New → Fix Committed
tags: added: backport-proposed
Krzysztof Kosinski (tweenk) wrote :

Backported to stable in 9864

Changed in inkscape:
milestone: 0.49 → 0.48.3
tags: removed: backport-proposed
Changed in inkscape:
importance: Undecided → Medium
Ted Gould (ted) on 2012-02-15
Changed in inkscape:
status: Fix Committed → Fix Released
su_v (suv-lp) wrote :

Follow-up report filed with remaining issues (as far as known):
Bug #992124 “RFE: clang support”
<https://bugs.launchpad.net/inkscape/+bug/992124>

To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers