FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > Debian > Debian GCC

 
 
LinkBack Thread Tools
 
Old 02-04-2010, 02:10 PM
Camm Maguire
 
Default Bug#568398: gcc-4.4: Error casting double complex to char

Package: gcc-4.4
Version: 4.4.3-1
Severity: important

dd.c:
#include <stdio.h>
#include <complex.h>

int main(int argc,char * argv[]) {

double complex d=0;
long l;

sscanf(argv[1],"%ld",&l);
d=l;
printf("%d %d %d %d %f
",(char)d,(short)d,(int)d,(long)d,(double)d);

return 0;

}


camm@localhost:$ cc -g /tmp/dd.c -o /tmp/dd
camm@localhost:$ /tmp/dd 1
1 1 1 1 1.000000
camm@localhost:$ /tmp/dd 255
-1 255 255 255 255.000000
camm@localhost:$ /tmp/dd 256
0 256 256 256 256.000000
camm@localhost:$ /tmp/dd 257
1 257 257 257 257.000000
camm@localhost:$ /tmp/dd 65535
0 -32768 65535 65535 65535.000000
camm@localhost:$ /tmp/dd 32768
0 -32768 32768 32768 32768.000000
camm@localhost:$ /tmp/dd 32767
-1 32767 32767 32767 32767.000000
camm@localhost:$ /tmp/dd 32766
-2 32766 32766 32766 32766.000000
camm@localhost:$ /tmp/dd 2147483647
0 -32768 2147483647 2147483647 2147483647.000000

Take care,

-- System Information:
Debian Release: squeeze/sid
APT prefers unstable
APT policy: (500, 'unstable')
Architecture: i386 (i686)

Kernel: Linux 2.6.28.7 (SMP w/2 CPU cores)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash

Versions of packages gcc-4.4 depends on:
ii binutils 2.20-5 The GNU assembler, linker and bina
ii cpp-4.4 4.4.3-1 The GNU C preprocessor
ii gcc-4.4-base 4.4.3-1 The GNU Compiler Collection (base
ii libc6 2.10.2-5 Embedded GNU C Library: Shared lib
ii libgcc1 1:4.4.3-1 GCC support library
ii libgomp1 4.4.3-1 GCC OpenMP (GOMP) support library

Versions of packages gcc-4.4 recommends:
ii libc6-dev 2.10.2-5 Embedded GNU C Library: Developmen

Versions of packages gcc-4.4 suggests:
pn gcc-4.4-doc <none> (no description available)
pn gcc-4.4-locales <none> (no description available)
pn gcc-4.4-multilib <none> (no description available)
pn libcloog-ppl0 <none> (no description available)
pn libgcc1-dbg <none> (no description available)
pn libgomp1-dbg <none> (no description available)
pn libmudflap0-4.4-dev <none> (no description available)
pn libmudflap0-dbg <none> (no description available)
pn libppl-c2 <none> (no description available)
pn libppl7 <none> (no description available)

-- no debconf information



--
To UNSUBSCRIBE, email to debian-gcc-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
 
Old 03-09-2010, 11:50 AM
Falk Hueffner
 
Default Bug#568398: gcc-4.4: Error casting double complex to char

tags 568398 + moreinfo
thanks

On Thu, Feb 04, 2010 at 10:10:00AM -0500, Camm Maguire wrote:
> dd.c:
> #include <stdio.h>
> #include <complex.h>
>
> int main(int argc,char * argv[]) {
> double complex d=0;
> long l;
>
> sscanf(argv[1],"%ld",&l);
> d=l;
> printf("%d %d %d %d %f
",(char)d,(short)d,(int)d,(long)d,(double)d);
>
> return 0;
> }
>
>
> camm@localhost:$ cc -g /tmp/dd.c -o /tmp/dd
> camm@localhost:$ /tmp/dd 1
> 1 1 1 1 1.000000
> camm@localhost:$ /tmp/dd 255
> -1 255 255 255 255.000000
> camm@localhost:$ /tmp/dd 256
> 0 256 256 256 256.000000
> camm@localhost:$ /tmp/dd 257
> 1 257 257 257 257.000000
> camm@localhost:$ /tmp/dd 65535
> 0 -32768 65535 65535 65535.000000
> camm@localhost:$ /tmp/dd 32768
> 0 -32768 32768 32768 32768.000000
> camm@localhost:$ /tmp/dd 32767
> -1 32767 32767 32767 32767.000000
> camm@localhost:$ /tmp/dd 32766
> -2 32766 32766 32766 32766.000000
> camm@localhost:$ /tmp/dd 2147483647
> 0 -32768 2147483647 2147483647 2147483647.000000

The conversion from double to char is only defined if the value of the
double, after discarding the fractional part, fits within the value
range of char. In your examples, this is only the case for the first
example, where the result seems correct. So please explain what the
output you expected is.

Falk



--
To UNSUBSCRIBE, email to debian-gcc-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
Archive: 20100309125016.GA14698@minet.uni-jena.de">http://lists.debian.org/20100309125016.GA14698@minet.uni-jena.de
 

Thread Tools




All times are GMT. The time now is 01:03 AM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org