[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Weird behavior of nested functions
From: |
Jeroen Dekkers |
Subject: |
Re: Weird behavior of nested functions |
Date: |
Mon, 10 Nov 2003 20:43:42 +0100 |
User-agent: |
Mutt/1.5.4i |
On Mon, Nov 10, 2003 at 06:44:35PM +0100, Marco Gerards wrote:
> Jeroen Dekkers <address@hidden> writes:
>
> > On Mon, Nov 10, 2003 at 10:10:52AM +0100, Yoshinori K. Okuji wrote:
> > > On Monday 10 November 2003 00:11, Marco Gerards wrote:
> > > > Is it possible that some object files for the utils and pupa mix up?
> > >
> > > No. The files in utils are compiled without -mrtd or -mregparm, because
> > > otherwise they are incompatible against your C library. So it is
> > > necessary to
> > > compile files in PUPA in per-target basis.
> > >
> > > BTW, are you good at reading assembly code generated by GCC? For this
> > > kind of
> > > problem, it is inevitable to take a look at what GCC produced. I myself
> > > will
> > > try your code as soon as possible.
> >
> > It's a gcc bug triggered by the combination of -mregparm=3 and nested
> > functions. The problem is that it wants to put the address of test in
> > %ecx but that register is also used for the third argument with
> > -mregparm=3. Below is a copy of the assembly code generated by gcc.
>
> How should this be fixed for PUPA? I assume not supporting some gcc
> versions is no option. ;)
>
> I see two options:
>
> - Not using -mregparm=3 anymore. This can be made dependent on the
> gcc version with autoconf I assume.
>
> - When using nested functions with more than 3 parameters an attribute
> should be used for this function to disable regparm. This can also
> be dependent on the gcc version.
>
> To me the second option seems the best. Does anyone see other options
> or does someone have an preference? If not I'll use option 2.
What about not using nested functions at all? They aren't really
necessary.
Jeroen Dekkers