Skip to Content.
Sympa Menu

cgal-discuss - Re: [cgal-discuss] frounding math trouble with GCC 4.0.1

Subject: CGAL users discussion list

List archive

Re: [cgal-discuss] frounding math trouble with GCC 4.0.1


Chronological Thread 
  • From: Ben Supnik <>
  • To:
  • Subject: Re: [cgal-discuss] frounding math trouble with GCC 4.0.1
  • Date: Thu, 28 May 2009 12:17:37 +0200

Hi Guys,

Right -- having a check in the debug code to catch this compiler flag is a nice thing...when I had rounding math off (the default on OS X) with 3.1 the problem manifest itself in low level precondition failures deep in the code. :-(

cheers
Ben

Shamyl Zakariya wrote:
Thanks!

I already had 4.2 installed ( owing to the iPhone dev SDK ) but on the command line usr/bin/gcc and /usr/bin/c++ pointed to 4.0 -- I reassigned the symlinks and rebuilt. THat being said, the real key -- what I didn't realize -- was that since CGAL appears to be mostly headers anyway, my files which include cgal headers need to be built with -frounding-math.

Turning on that flag for those files has fixed the problem.

And, hopefully with 4.2 it will optimize better!

Thanks everybody,


On May 27, 2009, at 8:50 AM, Sylvain Pion wrote:

Shamyl Zakariya wrote:
I just installed CGAL 3.4 ( was using 3.1 ) and on running my app,
CGAL terminates with the following error during static initialization:
terminate called after throwing an instance of 'CGAL::Assertion_exception'
what(): CGAL ERROR: assertion violation!
Expr: -CGAL_IA_MUL(-1.1, 10.1) != CGAL_IA_MUL(1.1, 10.1)
File: /usr/local/include/CGAL/Interval_nt.h
Line: 154
Explanation: Wrong rounding: did you forget the -frounding-math option
if you use GCC?
This is on Mac OS X, 10.5.7
So, assuming I made some sort of mistake during the configuration of
CGAL, I redownloaded the tarball and reconfigured it as such:
# cmake . -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=FALSE
And I'm seeing the following during configuration, which implies to me
that the build system is automatically adding -frounding-math...
-- Targetting Unix Makefiles
-- Using /opt/local/bin/c++ compiler.
-- DARWIN_VERSION=9
-- Mac Leopard detected
-- USING CMake version: 2.6.4
-- System: Darwin
-- USING GCC_VERSION = '4.0.1 (Apple Inc. build 5490)'
-- Using gcc version 4 or later. Adding -frounding-math
-- Build type: Release
-- USING CXXFLAGS = ' -frounding-math -O3 -DNDEBUG'
However, ever after this rebuild/reinstall my apps still die on the assertion.
(Please note, I'm not using any of the optional numeric packages, and
I'm using boost 1.36, and cmake 2.6)

I'm not sure what you mean exactly by "optional numeric packages",
but this check is useful as soon as you use CGAL::Interval_nt, which
is used in the filtered kernels (e.g. when you use Delaunay).

This check can be disabled with -DCGAL_DISABLE_ROUNDING_MATH_CHECK
(though of course you should never have to do that).

However, note that -DNDEBUG (which you have), also should disable this check.
Which means that the flags you see are not passed to the compilation
process correctly. Note that -frounding-math is also needed when
compiling/installing CGAL itself.

I'm not proficient enough in CMake to tell what can go wrong there,
maybe someone else can help.


Side note : Apple's g++ 4.0.1 is strongly discouraged for CGAL as soon
as you want to compile with optimization (you can e.g. upgrade Xcode
to get g++ 4.2).

--
Sylvain Pion
INRIA Sophia-Antipolis
Geometrica Project-Team
CGAL, http://cgal.org/
--
You are currently subscribed to cgal-discuss.
To unsubscribe or access the archives, go to
https://lists-sop.inria.fr/wws/info/cgal-discuss


--
Scenery Home Page: http://scenery.x-plane.com/
Scenery blog: http://xplanescenery.blogspot.com/
Plugin SDK: http://www.xsquawkbox.net/xpsdk/
X-Plane Wiki: http://wiki.x-plane.com/
Scenery mailing list:

Developer mailing list:





Archive powered by MHonArc 2.6.16.

Top of Page