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



             Bug #: 55746

           Summary: vfprintf behaves differently variable on stack vs

                    const argument.

    Classification: Unclassified

           Product: gcc

           Version: 4.2.1

            Status: UNCONFIRMED

          Severity: normal

          Priority: P3

         Component: c

        AssignedTo: unassig...@gcc.gnu.org

        ReportedBy: lb...@hotmail.com





Here is the test code that behaves differently w.r.t vfprintf. In one case it

prints the string where as in other case it crashes.



#include <stdarg.h>

#include <stdio.h>

int main(int argc, const char **argv)

{

    const char *var = "Test VarArg\n";



    asm("nop");

    asm("nop");

    vfprintf(stdout, "TestMe\n", 0);

    asm("nop");

    asm("nop");

    fflush(stdout);

    asm("nop");

    asm("nop");

    vfprintf(stdout, var, 0);

    asm("nop");

    asm("nop");

    fflush(stdout);



    return 0;

}



#gcc -g -o t3 t3.c 

#./t3

TestMe

Segfault





In first case vfprintf is optimized with _fwrite in the second case it uses

_vfprintf and crashes probably in va_copy.



thanks in advance.

lb

Reply via email to