This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/12503] New: __builtin_apply_args fails on sparc-sun-solaris2.9


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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]