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++/14278] New: fails when calling through a function pointer


Also fails on i686-pc-linux-gun.

When calling a function through a function pointer, and the return type is
passed to a constructor whose return type is also passed through a constructor,
G++ 3.4 fails to parse the expressions.

The feature this test excersizes is used by num_util, a collection of helper
functions that extends Boost.Python's interface with Numeric Python.  G++ 3.3
compiles this without error.

Thanks,
Jonathan Brandmeyer

pion:~/src jonathan$ g++-3.4 -v -c funcptr_crash.cpp 
Reading specs from /usr/local/lib/gcc/powerpc-apple-darwin7.2.0/3.4.0/specs
Configured with: ../gcc/configure --program-suffix=-3.4
--enable-version-specific-runtime-libs --disable-shared --enable-static
--enable-languages=c,c++
Thread model: posix
gcc version 3.4.0 20040223 (prerelease)
 /usr/local/libexec/gcc/powerpc-apple-darwin7.2.0/3.4.0/cc1plus -quiet -v
-D__DYNAMIC__ funcptr_crash.cpp -fPIC -quiet -dumpbase funcptr_crash.cpp
-auxbase funcptr_crash -version -o /var/tmp//ccRG1xS6.s
ignoring nonexistent directory "NONE/include"
ignoring nonexistent directory
"/usr/local/lib/gcc/powerpc-apple-darwin7.2.0/3.4.0/../../../../powerpc-apple-darwin7.2.0/include"
#include "..." search starts here:
#include <...> search starts here:
 /usr/local/lib/gcc/powerpc-apple-darwin7.2.0/3.4.0/include/c++
 /usr/local/lib/gcc/powerpc-apple-darwin7.2.0/3.4.0/include/c++/powerpc-apple-darwin7.2.0
 /usr/local/lib/gcc/powerpc-apple-darwin7.2.0/3.4.0/include/c++/backward
 /usr/local/include
 /usr/local/lib/gcc/powerpc-apple-darwin7.2.0/3.4.0/include
 /usr/include
End of search list.
GNU C++ version 3.4.0 20040223 (prerelease) (powerpc-apple-darwin7.2.0)
        compiled by GNU C version 3.4.0 20040223 (prerelease).
GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=4096
funcptr_crash.cpp:38: error: expected `)' before "visual_PyArrayHandle"
funcptr_crash.cpp:38: error: expected `)' before "visual_PyArrayHandle"
funcptr_crash.cpp:38: error: expected `,' or `...' before "visual_PyArrayHandle"
funcptr_crash.cpp:38: error: function `object ret(handle<PyObject>)' is
initialized like a variable
funcptr_crash.cpp:38: error: expected `,' or `;' before ')' token
----------------------------------------------------------------------  


typedef struct _object {
 int ob_refcnt; 
 struct _typeobject *ob_type;
} PyObject;

void **visual_PyArrayHandle;


template <class T = PyObject>
class handle
{
 public:

    template <class Y>
    explicit handle(Y* p)
        : m_p(static_cast<T*>(p))
    {
    }

    T* get() { return m_p; }
 private:
    T* m_p;
};

class object {
 private:
     PyObject* obj;
 public:
    template<class T>
    object( handle<T> other) :obj(static_cast<PyObject*>(other.get()))
    {}
};

// Changing the function pointer type to have less than these two arguments
// passes.  This one fails:
object ret(handle<>
      ((*(PyObject * (*)( int, int)) visual_PyArrayHandle[0])(0, 0)));
// This passes:
handle<> ret2
      ((*(PyObject * (*)( int, int)) visual_PyArrayHandle[0])(0, 0));
// As does this:
object ret3(handle<>
      ((*(PyObject * (*)( int)) visual_PyArrayHandle[0])(0)));

-- 
           Summary: fails when calling through a function pointer
           Product: gcc
           Version: 3.4.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: jbrandmeyer at earthlink dot net
                CC: gcc-bugs at gcc dot gnu dot org
  GCC host triplet: powerpc-apple-darwin7.2


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


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