public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/44942]  New: Bug in argument passing of long double
@ 2010-07-15  2:39 pdox at alum dot mit dot edu
  2010-07-15  8:06 ` [Bug target/44942] " rguenth at gcc dot gnu dot org
                   ` (10 more replies)
  0 siblings, 11 replies; 12+ messages in thread
From: pdox at alum dot mit dot edu @ 2010-07-15  2:39 UTC (permalink / raw)
  To: gcc-bugs

On X86-64, the following code demonstrates how passing a long double as a fixed
 argument causes corruption of the following variable arguments.

#include <stdio.h>
#include <assert.h>
#include <stdarg.h>

void test(int a, int b, int c, int d, int e, int f, int g, long double h, ...)
{
  int i;
  va_list ap;

  va_start(ap, h);
  i = va_arg(ap, int);
  printf("Got %d, expected %d\n", i, 123456789);
  va_end(ap);
}

int main() {
  test(0, 0, 0, 0, 0, 0, 0, (long double)0.0, (int)123456789);
  return 0;
}


-- 
           Summary: Bug in argument passing of long double
           Product: gcc
           Version: 4.4.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: pdox at alum dot mit dot edu
 GCC build triplet: x86_64-linux-gnu
  GCC host triplet: x86_64-linux-gnu
GCC target triplet: x86_64-linux-gnu


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44942


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug target/44942] Bug in argument passing of long double
  2010-07-15  2:39 [Bug c/44942] New: Bug in argument passing of long double pdox at alum dot mit dot edu
@ 2010-07-15  8:06 ` rguenth at gcc dot gnu dot org
  2010-07-15  9:50 ` jakub at gcc dot gnu dot org
                   ` (9 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2010-07-15  8:06 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from rguenth at gcc dot gnu dot org  2010-07-15 08:06 -------
Confirmed.


-- 

rguenth at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
          Component|c                           |target
     Ever Confirmed|0                           |1
           Keywords|                            |wrong-code
      Known to fail|                            |3.3.3 4.1.2 4.3.4 4.4.3
                   |                            |4.5.0 4.6.0
   Last reconfirmed|0000-00-00 00:00:00         |2010-07-15 08:06:24
               date|                            |


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44942


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug target/44942] Bug in argument passing of long double
  2010-07-15  2:39 [Bug c/44942] New: Bug in argument passing of long double pdox at alum dot mit dot edu
  2010-07-15  8:06 ` [Bug target/44942] " rguenth at gcc dot gnu dot org
@ 2010-07-15  9:50 ` jakub at gcc dot gnu dot org
  2010-07-15 12:03 ` jakub at gcc dot gnu dot org
                   ` (8 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: jakub at gcc dot gnu dot org @ 2010-07-15  9:50 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from jakub at gcc dot gnu dot org  2010-07-15 09:49 -------
Seems ix86_function_arg_advance ignores padding for > 8 byte aligned arguments
when updating cum->words.

With:
#include <stdarg.h>

long double
test (int a, int b, int c, int d, int e, int f, int g, int g2, int g3, long
double h, int g4, long double h2, int g5, long double h3, ...)
{
  int i;
  va_list ap;

  va_start (ap, h3);
  i = va_arg (ap, int);
  __builtin_printf ("Got %d, expected %d\n", i, 123456789);
  va_end (ap);
  return h + h2 + h3 + g3 + g4 + g5;
}

int
main ()
{
  test (0, 0, 0, 0, 0, 0, 0, 0, 0, 0.0L, 0, 0.0L, 0, 0.0L, 123456789,
0xaaaaaaaaaaaaaaaaULL, 0x5555555555555555ULL);
  return 0;
}

testcase the reading of the va_arg is already off by 24 bytes (3 times 8 byte
padding before each of the long double arguments).
Looking into it.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44942


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug target/44942] Bug in argument passing of long double
  2010-07-15  2:39 [Bug c/44942] New: Bug in argument passing of long double pdox at alum dot mit dot edu
  2010-07-15  8:06 ` [Bug target/44942] " rguenth at gcc dot gnu dot org
  2010-07-15  9:50 ` jakub at gcc dot gnu dot org
@ 2010-07-15 12:03 ` jakub at gcc dot gnu dot org
  2010-07-16  9:06 ` jakub at gcc dot gnu dot org
                   ` (7 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: jakub at gcc dot gnu dot org @ 2010-07-15 12:03 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from jakub at gcc dot gnu dot org  2010-07-15 12:03 -------
Created an attachment (id=21209)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=21209&action=view)
gcc46-pr44942.patch

Untested fix.  Grep tells me that cum->words is only ever used for x86-64
va_start expansion (and only for non-ms ABI), so I hope this patch doesn't
affect anything but __builtin_va_start in functions where at least one of the
arguments passed on the stack had to be padded.


-- 

jakub at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|unassigned at gcc dot gnu   |jakub at gcc dot gnu dot org
                   |dot org                     |
             Status|NEW                         |ASSIGNED


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44942


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug target/44942] Bug in argument passing of long double
  2010-07-15  2:39 [Bug c/44942] New: Bug in argument passing of long double pdox at alum dot mit dot edu
                   ` (2 preceding siblings ...)
  2010-07-15 12:03 ` jakub at gcc dot gnu dot org
@ 2010-07-16  9:06 ` jakub at gcc dot gnu dot org
  2010-07-16 10:35 ` jakub at gcc dot gnu dot org
                   ` (6 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: jakub at gcc dot gnu dot org @ 2010-07-16  9:06 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from jakub at gcc dot gnu dot org  2010-07-16 09:06 -------
Subject: Bug 44942

Author: jakub
Date: Fri Jul 16 09:06:02 2010
New Revision: 162255

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=162255
Log:
        PR target/44942
        * config/i386/i386-protos.h (ix86_function_arg_boundary): Change second
        argument to const_tree.
        * config/i386/i386.c (function_arg_advance): If padding needs to be
        inserted before argument, increment cum->words by number of padding
        words as well.
        (contains_aligned_value_p): Change argument to const_tree.
        (ix86_function_arg_boundary): Change second argument to const_tree.

        * gcc.c-torture/execute/pr44942.c: New test.
        * gcc.target/i386/pr44942.c: New test.

Added:
    trunk/gcc/testsuite/gcc.c-torture/execute/pr44942.c
    trunk/gcc/testsuite/gcc.target/i386/pr44942.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/config/i386/i386-protos.h
    trunk/gcc/config/i386/i386.c
    trunk/gcc/testsuite/ChangeLog


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44942


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug target/44942] Bug in argument passing of long double
  2010-07-15  2:39 [Bug c/44942] New: Bug in argument passing of long double pdox at alum dot mit dot edu
                   ` (3 preceding siblings ...)
  2010-07-16  9:06 ` jakub at gcc dot gnu dot org
@ 2010-07-16 10:35 ` jakub at gcc dot gnu dot org
  2010-07-22  6:42 ` jakub at gcc dot gnu dot org
                   ` (5 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: jakub at gcc dot gnu dot org @ 2010-07-16 10:35 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from jakub at gcc dot gnu dot org  2010-07-16 10:35 -------
Fixed on the trunk so far, will backport to branches later on.


-- 

jakub at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
      Known to fail|3.2.3 3.3.3 4.1.2 4.3.4     |3.2.3 3.3.3 4.1.2 4.3.4
                   |4.4.3 4.5.0 4.6.0           |4.4.3 4.5.0
      Known to work|                            |4.6.0


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44942


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug target/44942] Bug in argument passing of long double
  2010-07-15  2:39 [Bug c/44942] New: Bug in argument passing of long double pdox at alum dot mit dot edu
                   ` (4 preceding siblings ...)
  2010-07-16 10:35 ` jakub at gcc dot gnu dot org
@ 2010-07-22  6:42 ` jakub at gcc dot gnu dot org
  2010-07-22  6:46 ` jakub at gcc dot gnu dot org
                   ` (4 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: jakub at gcc dot gnu dot org @ 2010-07-22  6:42 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #6 from jakub at gcc dot gnu dot org  2010-07-22 06:42 -------
Subject: Bug 44942

Author: jakub
Date: Thu Jul 22 06:42:02 2010
New Revision: 162398

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=162398
Log:
        Backport from mainline
        2010-07-16  Jakub Jelinek  <jakub@redhat.com>

        PR target/44942
        * config/i386/i386-protos.h (ix86_function_arg_boundary): Change second
        argument to const_tree.
        * config/i386/i386.c (function_arg_advance): If padding needs to be
        inserted before argument, increment cum->words by number of padding
        words as well.
        (contains_aligned_value_p): Change argument to const_tree.
        (ix86_function_arg_boundary): Change second argument to const_tree.

        * gcc.c-torture/execute/pr44942.c: New test.
        * gcc.target/i386/pr44942.c: New test.

Added:
    branches/gcc-4_5-branch/gcc/testsuite/gcc.c-torture/execute/pr44942.c
    branches/gcc-4_5-branch/gcc/testsuite/gcc.target/i386/pr44942.c
Modified:
    branches/gcc-4_5-branch/gcc/ChangeLog
    branches/gcc-4_5-branch/gcc/config/i386/i386-protos.h
    branches/gcc-4_5-branch/gcc/config/i386/i386.c
    branches/gcc-4_5-branch/gcc/testsuite/ChangeLog


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44942


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug target/44942] Bug in argument passing of long double
  2010-07-15  2:39 [Bug c/44942] New: Bug in argument passing of long double pdox at alum dot mit dot edu
                   ` (5 preceding siblings ...)
  2010-07-22  6:42 ` jakub at gcc dot gnu dot org
@ 2010-07-22  6:46 ` jakub at gcc dot gnu dot org
  2010-07-22  6:49 ` jakub at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: jakub at gcc dot gnu dot org @ 2010-07-22  6:46 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #7 from jakub at gcc dot gnu dot org  2010-07-22 06:46 -------
Subject: Bug 44942

Author: jakub
Date: Thu Jul 22 06:46:28 2010
New Revision: 162399

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=162399
Log:
        Backport from mainline
        2010-07-16  Jakub Jelinek  <jakub@redhat.com>

        PR target/44942
        * config/i386/i386-protos.h (ix86_function_arg_boundary): Change second
        argument to const_tree.
        * config/i386/i386.c (function_arg_advance): If padding needs to be
        inserted before argument, increment cum->words by number of padding
        words as well.
        (contains_aligned_value_p): Change argument to const_tree.
        (ix86_function_arg_boundary): Change second argument to const_tree.

        * gcc.c-torture/execute/pr44942.c: New test.
        * gcc.target/i386/pr44942.c: New test.

Added:
    branches/gcc-4_4-branch/gcc/testsuite/gcc.c-torture/execute/pr44942.c
    branches/gcc-4_4-branch/gcc/testsuite/gcc.target/i386/pr44942.c
Modified:
    branches/gcc-4_4-branch/gcc/ChangeLog
    branches/gcc-4_4-branch/gcc/config/i386/i386-protos.h
    branches/gcc-4_4-branch/gcc/config/i386/i386.c
    branches/gcc-4_4-branch/gcc/testsuite/ChangeLog


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44942


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug target/44942] Bug in argument passing of long double
  2010-07-15  2:39 [Bug c/44942] New: Bug in argument passing of long double pdox at alum dot mit dot edu
                   ` (6 preceding siblings ...)
  2010-07-22  6:46 ` jakub at gcc dot gnu dot org
@ 2010-07-22  6:49 ` jakub at gcc dot gnu dot org
  2010-08-06 23:23 ` ebotcazou at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: jakub at gcc dot gnu dot org @ 2010-07-22  6:49 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #8 from jakub at gcc dot gnu dot org  2010-07-22 06:48 -------
Should be fixed now for 4.4+.


-- 

jakub at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
      Known to fail|3.2.3 3.3.3 4.1.2 4.3.4     |3.2.3 3.3.3 4.1.2 4.3.4
                   |4.4.3 4.5.0                 |4.4.3 4.4.4 4.5.0
      Known to work|4.6.0                       |4.6.0 4.5.1 4.4.5
         Resolution|                            |FIXED


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44942


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug target/44942] Bug in argument passing of long double
  2010-07-15  2:39 [Bug c/44942] New: Bug in argument passing of long double pdox at alum dot mit dot edu
                   ` (9 preceding siblings ...)
  2010-08-06 23:23 ` ebotcazou at gcc dot gnu dot org
@ 2010-08-06 23:23 ` ebotcazou at gcc dot gnu dot org
  10 siblings, 0 replies; 12+ messages in thread
From: ebotcazou at gcc dot gnu dot org @ 2010-08-06 23:23 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #9 from ebotcazou at gcc dot gnu dot org  2010-08-06 23:23 -------
Subject: Bug 44942

Author: ebotcazou
Date: Fri Aug  6 23:22:52 2010
New Revision: 162967

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=162967
Log:
        PR target/44942
        * config/sparc/sparc.c (function_arg_advance): Always take into account
        the padding, if any.

Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/config/sparc/sparc.c


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44942


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug target/44942] Bug in argument passing of long double
  2010-07-15  2:39 [Bug c/44942] New: Bug in argument passing of long double pdox at alum dot mit dot edu
                   ` (7 preceding siblings ...)
  2010-07-22  6:49 ` jakub at gcc dot gnu dot org
@ 2010-08-06 23:23 ` ebotcazou at gcc dot gnu dot org
  2010-08-06 23:23 ` ebotcazou at gcc dot gnu dot org
  2010-08-06 23:23 ` ebotcazou at gcc dot gnu dot org
  10 siblings, 0 replies; 12+ messages in thread
From: ebotcazou at gcc dot gnu dot org @ 2010-08-06 23:23 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #10 from ebotcazou at gcc dot gnu dot org  2010-08-06 23:23 -------
Subject: Bug 44942

Author: ebotcazou
Date: Fri Aug  6 23:23:12 2010
New Revision: 162968

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=162968
Log:
        PR target/44942
        * config/sparc/sparc.c (function_arg_advance): Always take into account
        the padding, if any.

Modified:
    branches/gcc-4_5-branch/gcc/ChangeLog
    branches/gcc-4_5-branch/gcc/config/sparc/sparc.c


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44942


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug target/44942] Bug in argument passing of long double
  2010-07-15  2:39 [Bug c/44942] New: Bug in argument passing of long double pdox at alum dot mit dot edu
                   ` (8 preceding siblings ...)
  2010-08-06 23:23 ` ebotcazou at gcc dot gnu dot org
@ 2010-08-06 23:23 ` ebotcazou at gcc dot gnu dot org
  2010-08-06 23:23 ` ebotcazou at gcc dot gnu dot org
  10 siblings, 0 replies; 12+ messages in thread
From: ebotcazou at gcc dot gnu dot org @ 2010-08-06 23:23 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #11 from ebotcazou at gcc dot gnu dot org  2010-08-06 23:23 -------
Subject: Bug 44942

Author: ebotcazou
Date: Fri Aug  6 23:23:29 2010
New Revision: 162969

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=162969
Log:
        PR target/44942
        * config/sparc/sparc.c (function_arg_advance): Always take into account
        the padding, if any.

Modified:
    branches/gcc-4_4-branch/gcc/ChangeLog
    branches/gcc-4_4-branch/gcc/config/sparc/sparc.c


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44942


^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2010-08-06 23:23 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-07-15  2:39 [Bug c/44942] New: Bug in argument passing of long double pdox at alum dot mit dot edu
2010-07-15  8:06 ` [Bug target/44942] " rguenth at gcc dot gnu dot org
2010-07-15  9:50 ` jakub at gcc dot gnu dot org
2010-07-15 12:03 ` jakub at gcc dot gnu dot org
2010-07-16  9:06 ` jakub at gcc dot gnu dot org
2010-07-16 10:35 ` jakub at gcc dot gnu dot org
2010-07-22  6:42 ` jakub at gcc dot gnu dot org
2010-07-22  6:46 ` jakub at gcc dot gnu dot org
2010-07-22  6:49 ` jakub at gcc dot gnu dot org
2010-08-06 23:23 ` ebotcazou at gcc dot gnu dot org
2010-08-06 23:23 ` ebotcazou at gcc dot gnu dot org
2010-08-06 23:23 ` ebotcazou at gcc dot gnu dot org

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).