public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/55746] New: vfprintf behaves differently variable on stack vs const argument.
@ 2012-12-19 23:40 lbana at hotmail dot com
  2012-12-19 23:44 ` [Bug c/55746] " pinskia at gcc dot gnu.org
  0 siblings, 1 reply; 2+ messages in thread
From: lbana at hotmail dot com @ 2012-12-19 23:40 UTC (permalink / raw)
  To: gcc-bugs


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: unassigned@gcc.gnu.org
        ReportedBy: lbana@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


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2012-12-19 23:44 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-12-19 23:40 [Bug c/55746] New: vfprintf behaves differently variable on stack vs const argument lbana at hotmail dot com
2012-12-19 23:44 ` [Bug c/55746] " pinskia at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).