public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* optimization/6398: faulty code when inlining in a var-arged function
@ 2002-04-21 13:16 lucho
0 siblings, 0 replies; 5+ messages in thread
From: lucho @ 2002-04-21 13:16 UTC (permalink / raw)
To: gcc-gnats
>Number: 6398
>Category: optimization
>Synopsis: faulty code when inlining in a var-arged function
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: unassigned
>State: open
>Class: wrong-code
>Submitter-Id: net
>Arrival-Date: Sun Apr 21 13:16:01 PDT 2002
>Closed-Date:
>Last-Modified:
>Originator: Luchezar Belev
>Release: gcc-3.0
>Organization:
>Environment:
pentium III; linux-2.4.6; glibc-2.2 (does it matter?)
>Description:
This is some combination of:
1) function inlining (-O3)
2) no frame pointer (-fomit-frame-pointer)
2) var-args
and it seems like this is somehow confusing GCC 3.0
so it generates incorrect code
(haven't tested other GCC versions)
>How-To-Repeat:
compile this source with -O3 and -fomit-frame-pointer
and see the comment
----begin----
#include <stdarg.h>
#include <stdio.h>
/*
compile with these options: -O3 -fomit-frame-pointer
to let the bug to appear
The expected output of this code is "AAAAxyz\n" printed out on the console
and it does so when compiled with -O2 (or lower) or without -fomit-frami-pointer
One fact i've discovered that may be a hint:
in the assembly output, near the beginning of f2() function
one can notice that %ebp is used for addressing ("movl 4(%ebp), %ecx")
before it is loaded with some meaningful value for this purpose
*/
static void f1(unsigned p, char *fmt, va_list args)
{
char *h[2] = {"AAAA", "BBBB"};
char buf[128];
int l;
if (p > 1) return;
l = strlen(h[p]);
memcpy(buf, h[p], l);
vsnprintf(buf + l, 128 - l, fmt, args);
puts(buf);
}
void f2(int p, char *fmt, ...)
{
va_list args;
va_start(args, fmt);
f1(p, fmt, args);
va_end(args);
}
int main()
{
f2(0, "xyz\n");
return 0;
}
----end----
>Fix:
don't know how to fix, but found a clue that may help: see the comment in the source
>Release-Note:
>Audit-Trail:
>Unformatted:
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: optimization/6398: faulty code when inlining in a var-arged function
@ 2002-12-06 15:30 reichelt
0 siblings, 0 replies; 5+ messages in thread
From: reichelt @ 2002-12-06 15:30 UTC (permalink / raw)
To: gcc-bugs, gcc-prs, lucho, nobody
Synopsis: faulty code when inlining in a var-arged function
State-Changed-From-To: feedback->closed
State-Changed-By: reichelt
State-Changed-When: Fri Dec 6 15:30:49 2002
State-Changed-Why:
Seems to be fixed.
I could reproduce the bug with gcc 3.0, but not with 3.0.4,
3.1, 3.2.1 and 3.3-20021118.
http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=6398
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: optimization/6398: faulty code when inlining in a var-arged function
@ 2002-04-22 9:46 lucho
0 siblings, 0 replies; 5+ messages in thread
From: lucho @ 2002-04-22 9:46 UTC (permalink / raw)
To: nobody; +Cc: gcc-prs
The following reply was made to PR optimization/6398; it has been noted by GNATS.
From: lucho <lucho@haemimont.bg>
To: jakub@gcc.gnu.org, gcc-bugs@gcc.gnu.org, gcc-prs@gcc.gnu.org,
lucho@haemimont.bg, nobody@gcc.gnu.org, gcc-gnats@gcc.gnu.org
Cc:
Subject: Re: optimization/6398: faulty code when inlining in a var-arged function
Date: Mon, 22 Apr 2002 18:45:29 +0300
This is a multi-part message in MIME format.
--------------010302030908040209010702
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit
here is the preprocessed source (as attachment)
i haven't installed other gcc than 3.0 yet and so cannot test other versions
--------------010302030908040209010702
Content-Type: text/plain;
name="bug.i"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="bug.i"
# 1 "bug.c"
# 1 "/usr/lib/gcc-lib/i686-pc-linux-gnu/3.0/include/stdarg.h" 1 3
# 43 "/usr/lib/gcc-lib/i686-pc-linux-gnu/3.0/include/stdarg.h" 3
typedef __builtin_va_list __gnuc_va_list;
# 110 "/usr/lib/gcc-lib/i686-pc-linux-gnu/3.0/include/stdarg.h" 3
typedef __gnuc_va_list va_list;
# 2 "bug.c" 2
static void f1(int p, char *fmt, va_list args)
{
char *hdr[2] = {"AAAA", "BBBB"};
char buf[128];
int l;
if (p > 2) return;
l = strlen(hdr[p]);
memcpy(buf, hdr[p], l);
vsnprintf(buf + l, 128 - l, fmt, args);
puts(buf);
}
void f2(int p, char *fmt, ...)
{
va_list args;
__builtin_stdarg_start((args),fmt);
f1(p, fmt, args);
__builtin_va_end(args);
}
int main()
{
f2(0, "xyz");
return 0;
}
--------------010302030908040209010702--
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: optimization/6398: faulty code when inlining in a var-arged function
@ 2002-04-21 14:45 jakub
0 siblings, 0 replies; 5+ messages in thread
From: jakub @ 2002-04-21 14:45 UTC (permalink / raw)
To: gcc-bugs, gcc-prs, lucho, nobody
Synopsis: faulty code when inlining in a var-arged function
State-Changed-From-To: open->feedback
State-Changed-By: jakub
State-Changed-When: Sun Apr 21 14:45:03 2002
State-Changed-Why:
Hard to say because the testcase is not preprocessed
and thus it matters a lot what exact glibc headers it has.
I couldn't reproduce this with 3.1 20020417 (prerelease),
nor 3.0.2 20011002, nor 3.0.4 (glibc 2.2.5 installed).
Can you please provide preprocessed source for the testcase?
http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=6398
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: optimization/6398: faulty code when inlining in a var-arged function
@ 2002-04-21 13:46 Andrew Pinski
0 siblings, 0 replies; 5+ messages in thread
From: Andrew Pinski @ 2002-04-21 13:46 UTC (permalink / raw)
To: nobody; +Cc: gcc-prs
The following reply was made to PR optimization/6398; it has been noted by GNATS.
From: Andrew Pinski <pinskia@physics.uc.edu>
To: lucho@haemimont.bg
Cc: gcc-gnats@gcc.gnu.org
Subject: Re: optimization/6398: faulty code when inlining in a var-arged function
Date: Sun, 21 Apr 2002 16:41:45 -0400
This has been fixed in gcc version 3.2 20020421 (experimental).
Could you test 3.1 prelease?
Thanks,
Andrew Pinski
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2002-12-06 23:30 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-04-21 13:16 optimization/6398: faulty code when inlining in a var-arged function lucho
2002-04-21 13:46 Andrew Pinski
2002-04-21 14:45 jakub
2002-04-22 9:46 lucho
2002-12-06 15:30 reichelt
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).