This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: [RFC] Eliminate NESTED_ATTR_FUNC
- From: "Vladimir 'phcoder' Serbinenko" <phcoder at gmail dot com>
- To: The development of GRUB 2 <grub-devel at gnu dot org>
- Cc: gcc at gnu dot org
- Date: Thu, 3 Sep 2009 17:06:45 +0200
- Subject: Re: [RFC] Eliminate NESTED_ATTR_FUNC
- References: <d7ead6de0909010642yd2e4a96r565ce5328d65b078@mail.gmail.com> <ca0f59980909010843w2bf56745j138f479732b1f721@mail.gmail.com> <ca0f59980909012120m2c422e6flef0e9ba607036542@mail.gmail.com>
> Hi,
>
> Oh, I was wrong previously, gcc does respect __attribute__
> ((__regparm__ (3))) flag (I forget to add -Os so it still uses stack
> to store value). And the bug is still there ! Try this test program:
I confirm with gcc-4.4
This is a grave problem then. This check was added by Marco Gerards
(maintainer) in 2003. He added a workaround but I don't believe such
behaviour to be correct. We're both GNU projects. IMO the correct
action would have been to report the bug to gcc-devel and refuse to
compile unless bug is fixed. This way users would update to newer gcc
patchlevel (e.g. 4.2.(X+1) instead of 4.2.X) instead of compiling with
buggy compiler. One GNU project shouldn't have expensive workaround
(we had bugs because of NESTED_FUNC_ATTR misuse)
Now we're in feature freeze but I hope in the future we'll be able to
change to correct behaviour when freeze is over.
>
> #include <stdio.h>
>
> void foo (int a, int b, void (*hook) (int aa, int bb, int cc))
> {
> ?b += a;
> ?hook (a, b, a + b);
> }
>
> void qq (int a)
> {
> ?auto void q1 (int aa, int bb, int cc);
> ?void q1 (int aa, int bb, int cc)
> ? ?{
> ? ? ?printf ("%d %d %d\n", a, aa + bb, cc);
> ? ?}
>
> ?foo (a, a + 1, q1);
> }
>
> int main()
> {
> ?qq (10);
> }
>
> Compile with:
> gcc -m32 -mregparm=3 -Os test.c
>
> ./a.out
> 10 31 -6674368
>
> gcc is 4.3.4 from debian.
> ---
> Bean
>
> gitgrub home: http://github.com/grub/grub/
> my fork page: http://github.com/bean123/grub/
>
>
> _______________________________________________
> Grub-devel mailing list
> Grub-devel@gnu.org
> http://lists.gnu.org/mailman/listinfo/grub-devel
>
--
Regards
Vladimir 'phcoder' Serbinenko
Personal git repository: http://repo.or.cz/w/grub2/phcoder.git