[vox-tech] gdb segfaults when printing long double complex variables

Daniel Hurt dwhurt at ucdavis.edu
Thu Jun 10 08:48:41 PDT 2004


I know it does not help, but it is reproducible here on gdb 6.1.  Mind 
if I point this out in the Gentoo Forums and Bug Site?

Dan

Peter Jay Salzman wrote:
> Bug: GDB segfaults when printing long double complex variables.
> 
> Sample Code:
> 
> 1       #include <tgmath.h>
> 2       #include <stdio.h>
> 3
> 4       int main(void)
> 5       {
> 6               complex a;
> 7               double complex b;
> 8               long double complex c;
> 9
> 10              a = 5 + 2I;
> 11              printf("%f + %fi\n", __real__ a, __imag__ a);
> 12
> 13              b = 5.0 + 2.0I;
> 14              printf("%f + %fi\n", __real__ b, __imag__ b);
> 15
> 16              c = 5.0L + 2.0LI;
> 17              printf("%Lf + %Lfi\n", __real__ c, __imag__ c);
> 18
> 19              return 0;
> 20      }
> 
> 
> 
> The program runs fine:
> 
>    p at satan$ gcc-3.3 -g -W -Wall blah.c 
>    p at satan$ ./a.out 
>    5.000000 + 2.000000i
>    5.000000 + 2.000000i
>    5.000000 + 2.000000i
> 
> The program runs fine under gdb:
> 
>    (gdb) run
>    Starting program: /home/p/a.out 
>    5.000000 + 2.000000i
>    5.000000 + 2.000000i
>    5.000000 + 2.000000i
> 
>    Program exited normally.
> 
> But GDB itself cannot print long double complex variables without
> segfaulting:
> 
>    (gdb) break 18
>    Breakpoint 1 at 0x8048436: file blah.c, line 18.
>    (gdb) run
>    Starting program: /home/p/a.out 
>    5.000000 + 2.000000i
>    5.000000 + 2.000000i
>    5.000000 + 2.000000i
> 
>    Breakpoint 1, main () at blah.c:19
>    19              return 0;
>    (gdb) p a
>    $1 = 5 + 2 * I
>    (gdb) p b
>    $2 = 5 + 2 * I
>    (gdb) p c
>    Segmentation fault (core dumped)
> 
> This is very reproducible, unfortunately.  This bug showed up at the
> worst possible moment...
> 
> Pete
> 


More information about the vox-tech mailing list