From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 2154 invoked by alias); 19 Dec 2012 23:40:56 -0000 Received: (qmail 2139 invoked by uid 48); 19 Dec 2012 23:40:41 -0000 From: "lbana at hotmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c/55746] New: vfprintf behaves differently variable on stack vs const argument. Date: Wed, 19 Dec 2012 23:40:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: lbana at hotmail dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Changed-Fields: Message-ID: X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" MIME-Version: 1.0 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2012-12/txt/msg01922.txt.bz2 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 #include 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