* Re: [RFC] Eliminate NESTED_ATTR_FUNC
[not found] ` <ca0f59980909012120m2c422e6flef0e9ba607036542@mail.gmail.com>
@ 2009-09-03 15:06 ` Vladimir 'phcoder' Serbinenko
2009-09-03 15:54 ` Paolo Bonzini
0 siblings, 1 reply; 3+ messages in thread
From: Vladimir 'phcoder' Serbinenko @ 2009-09-03 15:06 UTC (permalink / raw)
To: The development of GRUB 2; +Cc: gcc
> 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
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [RFC] Eliminate NESTED_ATTR_FUNC
2009-09-03 15:06 ` [RFC] Eliminate NESTED_ATTR_FUNC Vladimir 'phcoder' Serbinenko
@ 2009-09-03 15:54 ` Paolo Bonzini
2009-09-03 16:52 ` Vladimir 'phcoder' Serbinenko
0 siblings, 1 reply; 3+ messages in thread
From: Paolo Bonzini @ 2009-09-03 15:54 UTC (permalink / raw)
To: Vladimir 'phcoder' Serbinenko; +Cc: The development of GRUB 2, gcc
>> #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
Ok, this was the only important part of the message to us GCC hackers. :-)
Can you please report a bug in bugzilla, saying which versions work and
which fail? Also can you write in the report what was your analysis
with respect to regparm?
Thanks!
Paolo
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [RFC] Eliminate NESTED_ATTR_FUNC
2009-09-03 15:54 ` Paolo Bonzini
@ 2009-09-03 16:52 ` Vladimir 'phcoder' Serbinenko
0 siblings, 0 replies; 3+ messages in thread
From: Vladimir 'phcoder' Serbinenko @ 2009-09-03 16:52 UTC (permalink / raw)
To: Paolo Bonzini; +Cc: The development of GRUB 2, gcc
On Thu, Sep 3, 2009 at 5:54 PM, Paolo Bonzini<bonzini@gnu.org> wrote:
>
>>> #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
>
> Ok, this was the only important part of the message to us GCC hackers. :-)
>
> Can you please report a bug in bugzilla, saying which versions work and
> which fail? Also can you write in the report what was your analysis with
> respect to regparm?
Done by Robert Millan here: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41246
>
> Thanks!
>
> Paolo
>
--
Regards
Vladimir 'phcoder' Serbinenko
Personal git repository: http://repo.or.cz/w/grub2/phcoder.git
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2009-09-03 16:52 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <d7ead6de0909010642yd2e4a96r565ce5328d65b078@mail.gmail.com>
[not found] ` <ca0f59980909010843w2bf56745j138f479732b1f721@mail.gmail.com>
[not found] ` <ca0f59980909012120m2c422e6flef0e9ba607036542@mail.gmail.com>
2009-09-03 15:06 ` [RFC] Eliminate NESTED_ATTR_FUNC Vladimir 'phcoder' Serbinenko
2009-09-03 15:54 ` Paolo Bonzini
2009-09-03 16:52 ` Vladimir 'phcoder' Serbinenko
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).