This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c/47533] [m68k] stack corruption with -Os (probably due to tail call optimisation)


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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]