Skip to Content.
Sympa Menu

cgal-discuss - Re: [cgal-discuss] Re: Crash with Nef_polyhedron_3

Subject: CGAL users discussion list

List archive

Re: [cgal-discuss] Re: Crash with Nef_polyhedron_3


Chronological Thread 
  • From: Joachim Reichel <(005b7a4cd6%hidden_head%005b7a4cd6)joachim.reichel(005b7a4cd6%hidden_at%005b7a4cd6)gmx.de(005b7a4cd6%hidden_end%005b7a4cd6)>
  • To: (005b7a4cd6%hidden_head%005b7a4cd6)cgal-discuss(005b7a4cd6%hidden_at%005b7a4cd6)lists-sop.inria.fr(005b7a4cd6%hidden_end%005b7a4cd6)
  • Subject: Re: [cgal-discuss] Re: Crash with Nef_polyhedron_3
  • Date: Tue, 29 May 2012 23:50:54 +0200

Hi,

On 05/29/2012 09:54 AM, Marius Kintel wrote:
> I think you may have hit the core of this issue.
> Somehow, I suspect that -frounding-math is not supported by llvm-gcc, or
> perhaps just Apple's version?
>
> Is there a way I can quickly determine if this compiler simply cannot be
> used with CGAL because of this?
>
> The annoying thing is that Apple gives us only two choices at the moment:
> llvm-gcc-4.2.1 or clang 3.1

to test the basic rounding mode stuff you could try the attached test case.

Joachim
#include <fenv.h>
#include <iostream>
#include <limits>

int modes[4] = { FE_TOWARDZERO, FE_UPWARD, FE_DOWNWARD, FE_TONEAREST };

std::string str (int mode)
{
	switch (mode)
		{
			case FE_TOWARDZERO: return "FE_TOWARDZERO";
			case FE_UPWARD:     return "FE_UPWARD";
			case FE_DOWNWARD:   return "FE_DOWNWARD";
			case FE_TONEAREST:  return "FE_TONEAREST";
			default:            throw __LINE__;
		}
}

// global variable to stop constant propagation
double eps;

int fetestround ()
{
	eps = std::numeric_limits<double>::denorm_min();

	double x = -1.0;
	double y =  1.0;
	double x_plus_eps  = x + eps;
	double y_minus_eps = y - eps;

	if ((x == x_plus_eps) && (y == y_minus_eps))
		return FE_TONEAREST;
	if (y == y_minus_eps)
		return FE_UPWARD;
	if (x == x_plus_eps)
		return FE_DOWNWARD;
	return FE_TOWARDZERO;
}

int main (int argc, char* argv[])
{
	int errors = 0;

	int mode_get = fegetround();
	std::cout << "fegetround() = " << str(mode_get) << "   " << std::endl;

	for (int i=0; i<4; i++)
		{
			int mode_set = modes[i];
			fesetround (mode_set);
			std::cout << "fesetround (" << str(mode_set) << ")" << std::endl;
			
			int mode_get = fegetround();
			std::cout << "fegetround() = " << str(mode_get) << "   ";
			bool ok_get = mode_get == mode_set;
			if (!ok_get)
				errors++;
			std::cout << (ok_get ? "(ok)" : "(error)") << std::endl;

			int mode_test = fetestround();
			std::cout << "fetestround() = " << str(mode_test) << "   ";
			bool ok_test = mode_test == mode_set;
			if (!ok_test)
				errors++;
			std::cout << (ok_test ? "(ok)" : "(error)") << std::endl;
		}

	return errors;
}



Archive powered by MHonArc 2.6.18.

Top of Page