This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/47533] [m68k] stack corruption with -Os (probably due to tail call optimisation)
- From: "mikpe at it dot uu.se" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Sat, 29 Jan 2011 17:35:24 +0000
- Subject: [Bug c/47533] [m68k] stack corruption with -Os (probably due to tail call optimisation)
- Auto-submitted: auto-generated
- References: <bug-47533-4@http.gcc.gnu.org/bugzilla/>
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47533
Mikael Pettersson <mikpe at it dot uu.se> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |mikpe at it dot uu.se
--- Comment #1 from Mikael Pettersson <mikpe at it dot uu.se> 2011-01-29 17:35:12 UTC ---
(In reply to comment #0)
> root@ara2:~ # ./a.out
> want: C0000010
> got1: C0000010
> syscall with 1, 258, 16 reached
> got2: 00000010
You don't really say what the error is. Is it that the number after got2
differs from the one after got1? Can you rewrite the test case so that it does
a runtime check and an exit(1) or similar if the error is detected?
> The problem is: baz(int, int, short) takes 3 arguments, but
> _can_ be called with two arguments only (how many people use the 3-argument
> form of open() unless itâs for O_CREAT anyway?).
Your assembly-coded bar() calls baz() with only two parameters even though
baz() is defined as a non-variadic function with three parameters. That's
totally invalid. If bar() had been in C you would have gotten a warning.
Looking in klibc-1.5.21 I see that the published prototype for open() is:
__extern int open(const char *, int, ...);
This looks fine, but the actual definition (which deliberately doesn't see the
above prototype) is:
int open(const char *pathname, int flags, mode_t mode)
{ ... }
This is invalid C, and very sloppy programming.