[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#318959: libc6: varying behaviour with different compiler/optimization combinations



Package: libc6
Version: 2.3.2.ds1-22
Followup-For: Bug #318959


Actually there is something wrong even without "volatile":

/* file: ki.c */
#include <stdio.h>
#include <math.h>

extern long int lround(double x);

int main()
{
    double b;
    long int i;
    b = 1.04866e+6;
    i = lround(b);
    printf("%e %ld %ld\n", b, lround(b), i);
    return 0;
}

try running the following bash script:

for c in 3.3 3.4 4.0; do
    for o in 0 1 2 3 ; do
        printf "gcc-%s -O%s\t" $c $o;
	gcc-$c -W -Wall -O$o  -std=c99 ki.c -lm;
	./a.out;
    done;
done

on my debian (stable, uniprocessor), the results are... mysterious:

gcc-3.3 -O0     1.048660e+06 -2146434988 -2146434988
gcc-3.3 -O1     1.048660e+06 -2146434988 -2146434988
gcc-3.3 -O2     1.048660e+06 -2146434988 -2146434988
gcc-3.3 -O3     1.048660e+06 -2146434988 -2146434988
gcc-3.4 -O0     1.048660e+06 -2146434988 -2146434988
gcc-3.4 -O1     1.048660e+06 -2146434988 -2146434988
gcc-3.4 -O2     1.048660e+06 -2146434988 -2146434988
gcc-3.4 -O3     1.048660e+06 -2146434988 -2146434988
gcc-4.0 -O0     1.048660e+06 -2146434988 -2146434988
gcc-4.0 -O1     1.048660e+06 1048660 1048660
gcc-4.0 -O2     1.048660e+06 1048660 1048660
gcc-4.0 -O3     1.048660e+06 1048660 1048660

-- System Information:
Debian Release: testing/unstable
  APT prefers testing
  APT policy: (500, 'stable')
Architecture: i386 (i686)
Shell:  /bin/sh linked to /bin/bash
Kernel: Linux 2.6.8-2-686-smp
Locale: LANG=C, LC_CTYPE=C (charmap=ANSI_X3.4-1968)

Versions of packages libc6 depends on:
ii  libdb1-compat                 2.1.3-7    The Berkeley database routines [gl

libc6 recommends no packages.

-- no debconf information



Reply to: