public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/12503] New: __builtin_apply_args fails on sparc-sun-solaris2.9
@ 2003-10-03 19:22 pierre dot nguyen-tuong at asim dot lip6 dot fr
  2003-10-03 19:26 ` [Bug c++/12503] " pierre dot nguyen-tuong at asim dot lip6 dot fr
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: pierre dot nguyen-tuong at asim dot lip6 dot fr @ 2003-10-03 19:22 UTC (permalink / raw)
  To: gcc-bugs

PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

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

           Summary: __builtin_apply_args fails on sparc-sun-solaris2.9
           Product: gcc
           Version: 3.3.1
            Status: UNCONFIRMED
          Severity: critical
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: pierre dot nguyen-tuong at asim dot lip6 dot fr
                CC: gcc-bugs at gcc dot gnu dot org

__builtin_apply_args do not put all arguments on the stack

Example (source code below):
- funcA is a variadic function
- funcB is a normal function
- funcA is called and should give all its arguments to funcB thanks to
__builtin_apply_args and __builtin_apply

main -> funcA(args) -> funcB(args)

Works fine on Linux, g++ 3.3.1, but fails on Solaris 2.9 gcc 3.3.1

Compile file demo.cpp with   g++ -Wall -o demo demo.cpp and run :

-------------------------------------------------------------------
#include <iostream>

#include <stdlib.h>
#include <stdarg.h>
#include <stdlib.h>

using namespace std ;


// Arguments : char *
//             double
//             double
//             double
//             int
//             int

extern "C" void funcB(char *name,double d,double e,double f,int g,int h)
{
  cout << "----------------------- funcB --------------------------------\n" ;

  cout << "---- arg #0 (name)    : " << &name << "  " << name << endl ;
  cout << "---- arg #1 (double)  : " << &d << "  " << d  << endl ;
  cout << "---- arg #2 (double)  : " << &e << "  " << e  << endl ;
  cout << "---- arg #3 (double)  : " << &f << "  " << f  << endl ;
  cout << "---- arg #4 (int)     : " << &g << "  " << g  << endl ;
  cout << "---- arg #5 (int)     : " << &h << "  " << h  << endl ;

  cout << "----------------------- End of funcB -------------------------\n" ;
}

extern "C" void funcA(char *name,...)
{
  int      size       = 0    ;
  void     *arguments = NULL ;
  va_list  ap         = NULL ;
  int      i          = 0    ;
  double   d          = 0.0  ;

  va_start(ap,name) ;

  cout << "----------------------- funcA --------------------------------\n" ;

  cout << "---- arg #0 (name)    : " << ap << "  " << name << endl ;

  d = va_arg(ap,double) ;

  cout << "---- arg #1 (double)  : " << ap << "  " << d  << endl ;

  d = va_arg(ap,double) ;

  cout << "---- arg #2 (double)  : " << ap << "  " << d  << endl ;

  d = va_arg(ap,double) ;

  cout << "---- arg #3 (double)  : " << ap << "  " << d  << endl ;

  i = va_arg(ap,int) ;

  cout << "---- arg #4 (int)     : " << ap << "  " << i  << endl ;

  i = va_arg(ap,int) ;

  cout << "---- arg #5 (int)     : " << ap << "  " << i  << endl ;

  va_end(ap) ;

  size = sizeof(char *) + 3 * sizeof(double) + 2 * sizeof(int) ;

  cout << "---- Size = " << size << endl ;

  arguments = __builtin_apply_args(size) ;

  cout << "---- Arg pointer = " << arguments << endl ;

  cout << "---- Calling function\n" ;

  __builtin_apply((void (*)(...))funcB,arguments,size) ;

  cout << "----------------------- End of funcA --------------------\n" ;
}


int main()
{
  funcA("eeee",5.444567,8.90765,4.567789,5,9076) ;

  return 0 ;
}

-------------------------------------------------------------------

Arguments 5 and 6 are missing in funcB.


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

end of thread, other threads:[~2003-11-27  6:25 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-10-03 19:22 [Bug c++/12503] New: __builtin_apply_args fails on sparc-sun-solaris2.9 pierre dot nguyen-tuong at asim dot lip6 dot fr
2003-10-03 19:26 ` [Bug c++/12503] " pierre dot nguyen-tuong at asim dot lip6 dot fr
2003-10-04  6:54 ` [Bug c++/12503] __builtin_apply_args fails ebotcazou at gcc dot gnu dot org
2003-10-04  7:07 ` ebotcazou at gcc dot gnu dot org
2003-10-04 14:16 ` ebotcazou at gcc dot gnu dot org
2003-11-27  6:25 ` [Bug middle-end/12503] " 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).