This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug optimization/12199] New: [3.3-hammer regression] long double miscompilation in gsl/amd64


PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=12199

           Summary: [3.3-hammer regression] long double miscompilation in
                    gsl/amd64
           Product: gcc
           Version: 3.3.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: optimization
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: gbeauchesne at mandrakesoft dot com
                CC: aj at suse dot de,gcc-bugs at gcc dot gnu dot org,jh at
                    suse dot cz
  GCC host triplet: x86_64-unknown-linux-gnu

Hi,

The following testcase reduced from gsl is miscompiled only with 3.3-hammer branch as of today. 
This is a  regression from plain 3.3-branch. Sounds like conversion from double to long double 
delta variable gets mad.

The bug is exhausted at -O2 and vanishes at -O1 or with extra -fno-regmove.
---
extern void abort (void);

static double
fabs (double x)
{
  return x < 0 ? -x : x;
}

static void
check (double result, double expected, double relative_error)
{
  int status = -1;

  if (result < 0 || result > 0)
	status = (fabs(result - expected)/fabs(expected) > relative_error);

  if (status)
	abort ();
}

int
main (void)
{
  const int na = 14;

  const double rawa[] =
  {.0421, .0941, .1064, .0242, .1331,
   .0773, .0243, .0815, .1186, .0356,
   .0728, .0999, .0614, .0479};

  double rel = 1e-10;

  {
	const double mean = 0.0728;
	const double expected = 0.00113837428571429;
	long double variance = 0 ;
	int i;

	for (i = 0; i < na; i++)
	  {
		const long double delta = (rawa[i] - mean);
		variance += (delta * delta - variance) / (i + 1);
	  }

    check (variance, expected, rel);
  }

  return 0;
}


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]