bogdan celer
05/17/2009 5:45 AM
post29599
|
a little prg2.c
#include <stdio.h>
#include <stdlib.h>
char buffer[1000];
int main()
{
long long b, a = -0x3AFAFAFAFAFAFAFALL;
int i;
for( i = 0; i < 100; ++i )
buffer[i] = '0';
sprintf (buffer, "%llu", a);
sscanf (buffer, "%llu", &b);
printf( "a = %llu \n", a );
printf( "buffer = %s \n", buffer );
printf( "b = %llu \n", b );
abort();
}
qcc/gcc -o prg2 prg2.c
# ./prg2
a = -4249985154237004538
buffer = -4249985154237004538
b = -4249985154237004538
Abort (core dumped)
# gdb prg2
GNU gdb 6.8 qnx-nto (rev. 297)
Copyright (C) 2008 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "i386-pc-nto-qnx6.4.0"...
(gdb) start
Temporary breakpoint 1 at 0x8048701: file prg2.c, line 6.
Starting program: /home/GCC/4.4/prg2
Temporary breakpoint 1, main () at prg2.c:6
6 long long b, a = -0x3AFAFAFAFAFAFAFALL;
(gdb) b 11
Breakpoint 2 at 0x804872b: file prg2.c, line 11.
(gdb) c
Continuing.
Breakpoint 2, main () at prg2.c:11
11 sprintf (buffer, "%lld", a);
(gdb) s
12 sscanf (buffer, "%lld", &b);
(gdb)
13 printf( "a = %lld \n", a );
(gdb)
a = -4249985154237004538
14 printf( "buffer = %s \n", buffer );
(gdb)
buffer = -4249985154237004538
15 printf( "b = %lld \n", b );
(gdb)
b = -4249985154237004538
16 abort();
(gdb)
Program received signal SIGABRT, Aborted.
0xb033da61 in SignalKill () from /usr/qnx641/target/qnx6/x86/lib/libc.so.3
(gdb)
Single stepping until exit from function SignalKill,
which has no line number information.
Program exited normally.
(gdb)
And in /var/dumps I see prg2.core
Why ????
|
|
|