source file :

/*
 * The execution gives wrong results when compiled with mingw32-gcc 3.4.2
 * (MinGW-5.1.3)
 * (no problem with previous mingw32-gcc 3.2.3 / MinGW-3.1.0)
 *
 *   KO when REAL = float
 *   OK when REAL = double
 *
 *   Expected results are : tab[0] = 123 and tab[1] = -123
 *
 *   If instead of 
 *
 *     *p++ = (REAL) floor((double) *p + 0.5);
 *     *p++ = (REAL) floor((double) *p + 0.5);
 *
 *   code is
 *
 *     *p = (REAL) floor((double) *p + 0.5);
 *     p++;
 *     *p = (REAL) floor((double) *p + 0.5);
 *     p++;
 *
 *   the execution is OK.
 */

#include <stdlib.h>
#include <stdio.h>
#include <math.h>

#define REAL  float  /* comment for use 'double' */

#ifndef REAL
#define REAL  double
#endif


int main()
{
  REAL  tab[2],*p;

  tab[0] =  123.456;
  tab[1] = -123.456;

  p = &tab[0];

  *p++ = (REAL) floor((double) *p + 0.5);
  *p++ = (REAL) floor((double) *p + 0.5);

  fprintf(stdout,">>> tab[0] = %f, tab[1] = %f\n",
                 (double) tab[0],(double) tab[1]);

  return 0;
}


-- 
           Summary: The execution gives wrong results when compiled with
                    mingw32-gcc 3.4.2
           Product: gcc
           Version: 3.4.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: alduc1 at free dot fr
 GCC build triplet: mingw32-gcc 3.4.2 / MinGW-5.1.3
  GCC host triplet: xp sp1
GCC target triplet: win32


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

Reply via email to