public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/14278] New: fails when calling through a function pointer
@ 2004-02-24 18:58 jbrandmeyer at earthlink dot net
  2004-02-24 19:15 ` [Bug c++/14278] [3.4/3.5 Regression] " pinskia at gcc dot gnu dot org
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: jbrandmeyer at earthlink dot net @ 2004-02-24 18:58 UTC (permalink / raw)
  To: gcc-bugs

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


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

* [Bug c++/14278] [3.4/3.5 Regression] fails when calling through a function pointer
  2004-02-24 18:58 [Bug c++/14278] New: fails when calling through a function pointer jbrandmeyer at earthlink dot net
@ 2004-02-24 19:15 ` pinskia at gcc dot gnu dot org
  2004-02-24 20:15 ` bangerth at dealii dot org
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-02-24 19:15 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-02-24 19:15 -------
I think this is valid code, anyways this is caused by Mark's patch to have better error messages for 
missing a ",".

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |mmitchel at gcc dot gnu dot
                   |                            |org
           Keywords|                            |rejects-valid
            Summary|fails when calling through a|[3.4/3.5 Regression] fails
                   |function pointer            |when calling through a
                   |                            |function pointer
   Target Milestone|---                         |3.4.0


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


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

* [Bug c++/14278] [3.4/3.5 Regression] fails when calling through a function pointer
  2004-02-24 18:58 [Bug c++/14278] New: fails when calling through a function pointer jbrandmeyer at earthlink dot net
  2004-02-24 19:15 ` [Bug c++/14278] [3.4/3.5 Regression] " pinskia at gcc dot gnu dot org
@ 2004-02-24 20:15 ` bangerth at dealii dot org
  2004-02-24 20:20 ` bangerth at dealii dot org
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: bangerth at dealii dot org @ 2004-02-24 20:15 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From bangerth at dealii dot org  2004-02-24 20:15 -------
Here's something smaller: 
---------------------- 
struct S {}; 
 
struct X { 
    X(S* p); 
}; 
 
struct A { 
    A(X); 
}; 
 
void *p_fun; 
A ret(X ((*(S* (*)(int, int)) p_fun)(0, 0))); 
------------------ 
 
W. 

-- 


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


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

* [Bug c++/14278] [3.4/3.5 Regression] fails when calling through a function pointer
  2004-02-24 18:58 [Bug c++/14278] New: fails when calling through a function pointer jbrandmeyer at earthlink dot net
  2004-02-24 19:15 ` [Bug c++/14278] [3.4/3.5 Regression] " pinskia at gcc dot gnu dot org
  2004-02-24 20:15 ` bangerth at dealii dot org
@ 2004-02-24 20:20 ` bangerth at dealii dot org
  2004-02-26 18:07 ` giovannibajo at libero dot it
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: bangerth at dealii dot org @ 2004-02-24 20:20 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From bangerth at dealii dot org  2004-02-24 20:20 -------
OK, this is the cleanest I can come up with: 
---------------- 
struct X { 
    X(int p); 
}; 
 
struct A { 
    A(X); 
}; 
 
void *p_fun; 
A a(X ((*(int (*)(int, int)) p_fun)(0, 0))); 
-------------------- 
 
I think the code is valid. It fails with 3.4 and mainline, though, 
while it compiles with 3.3.4: 
 
g/x> /home/bangerth/bin/gcc-3.3.4-pre/bin/c++ -c x.cc 
 
g/x> /home/bangerth/bin/gcc-3.4-pre/bin/c++ -c x.cc 
x.cc:10: error: expected `)' before "p_fun" 
x.cc:10: error: expected `)' before "p_fun" 
x.cc:10: error: expected `,' or `...' before "p_fun" 
x.cc:10: error: function `A a(X)' is initialized like a variable 
x.cc:10: error: expected `,' or `;' before ')' token 
 
g/x> /home/bangerth/bin/gcc-3.5-pre/bin/c++ -c x.cc 
x.cc:10: error: expected `)' before "p_fun" 
x.cc:10: error: expected `)' before "p_fun" 
x.cc:10: error: expected `,' or `...' before "p_fun" 
x.cc:10: error: function `A a(X)' is initialized like a variable 
x.cc:10: error: expected `,' or `;' before ')' token 
 
W. 

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|                            |1
      Known to fail|                            |3.4.0 3.5.0
      Known to work|                            |3.3.4
   Last reconfirmed|0000-00-00 00:00:00         |2004-02-24 20:20:07
               date|                            |


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


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

* [Bug c++/14278] [3.4/3.5 Regression] fails when calling through a function pointer
  2004-02-24 18:58 [Bug c++/14278] New: fails when calling through a function pointer jbrandmeyer at earthlink dot net
                   ` (2 preceding siblings ...)
  2004-02-24 20:20 ` bangerth at dealii dot org
@ 2004-02-26 18:07 ` giovannibajo at libero dot it
  2004-02-26 19:30 ` bangerth at dealii dot org
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: giovannibajo at libero dot it @ 2004-02-26 18:07 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From giovannibajo at libero dot it  2004-02-26 18:07 -------
Actually, you can't cast a void* to a function pointer, but (besides the parse 
error) we don't enforce this right now.

-- 


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


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

* [Bug c++/14278] [3.4/3.5 Regression] fails when calling through a function pointer
  2004-02-24 18:58 [Bug c++/14278] New: fails when calling through a function pointer jbrandmeyer at earthlink dot net
                   ` (3 preceding siblings ...)
  2004-02-26 18:07 ` giovannibajo at libero dot it
@ 2004-02-26 19:30 ` bangerth at dealii dot org
  2004-02-26 19:59 ` giovannibajo at libero dot it
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: bangerth at dealii dot org @ 2004-02-26 19:30 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From bangerth at dealii dot org  2004-02-26 19:30 -------
I don't think that's the problem here. This code should 
be valid, then: 
------------------------ 
struct X {  
    X(int p);  
};  
  
struct A {  
    A(X);  
};  
 
int (*p_fun)(int, int); 
A a(X ((*(int (*)(int, int)) p_fun)(0, 0))); 
--------------------- 
since we only cast p_fun to its exact same type. It fails with the 
same error, though. 
 
W. 

-- 


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


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

* [Bug c++/14278] [3.4/3.5 Regression] fails when calling through a function pointer
  2004-02-24 18:58 [Bug c++/14278] New: fails when calling through a function pointer jbrandmeyer at earthlink dot net
                   ` (4 preceding siblings ...)
  2004-02-26 19:30 ` bangerth at dealii dot org
@ 2004-02-26 19:59 ` giovannibajo at libero dot it
  2004-02-27  0:30 ` cvs-commit at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: giovannibajo at libero dot it @ 2004-02-26 19:59 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From giovannibajo at libero dot it  2004-02-26 19:59 -------
Wolfgang, 

I was not clear. I was saying that there is indeed a parse error (which is the 
bug covered in this PR), but the testcase you proposed was invalid because of 
the conversion issue (even if GCC doesn't currently enforce it, even for 
straightforward "void* p; (void (*)(void))p;"). 

Your new testcase is of course valid C++, so now it's a rejects-valid by all 
means.


-- 


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


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

* [Bug c++/14278] [3.4/3.5 Regression] fails when calling through a function pointer
  2004-02-24 18:58 [Bug c++/14278] New: fails when calling through a function pointer jbrandmeyer at earthlink dot net
                   ` (5 preceding siblings ...)
  2004-02-26 19:59 ` giovannibajo at libero dot it
@ 2004-02-27  0:30 ` cvs-commit at gcc dot gnu dot org
  2004-02-27  0:31 ` cvs-commit at gcc dot gnu dot org
  2004-02-27  0:32 ` mmitchel at gcc dot gnu dot org
  8 siblings, 0 replies; 10+ messages in thread
From: cvs-commit at gcc dot gnu dot org @ 2004-02-27  0:30 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From cvs-commit at gcc dot gnu dot org  2004-02-27 00:30 -------
Subject: Bug 14278

CVSROOT:	/cvs/gcc
Module name:	gcc
Branch: 	gcc-3_4-branch
Changes by:	mmitchel@gcc.gnu.org	2004-02-27 00:30:47

Modified files:
	gcc/testsuite  : ChangeLog 
	gcc/cp         : ChangeLog parser.c 
Added files:
	gcc/testsuite/g++.dg/parse: comma1.C 

Log message:
	PR c++/14278
	* parser.c (cp_parser_parameter_declaration_list): Commit
	to fewer tentative parses.
	
	PR c++/14278
	* g++.dg/parse/comma1.C: New test.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.3389.2.110&r2=1.3389.2.111
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/parse/comma1.C.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=NONE&r2=1.1.2.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.3892.2.60&r2=1.3892.2.61
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/parser.c.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.157.2.14&r2=1.157.2.15



-- 


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


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

* [Bug c++/14278] [3.4/3.5 Regression] fails when calling through a function pointer
  2004-02-24 18:58 [Bug c++/14278] New: fails when calling through a function pointer jbrandmeyer at earthlink dot net
                   ` (6 preceding siblings ...)
  2004-02-27  0:30 ` cvs-commit at gcc dot gnu dot org
@ 2004-02-27  0:31 ` cvs-commit at gcc dot gnu dot org
  2004-02-27  0:32 ` mmitchel at gcc dot gnu dot org
  8 siblings, 0 replies; 10+ messages in thread
From: cvs-commit at gcc dot gnu dot org @ 2004-02-27  0:31 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From cvs-commit at gcc dot gnu dot org  2004-02-27 00:31 -------
Subject: Bug 14278

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	mmitchel@gcc.gnu.org	2004-02-27 00:31:50

Modified files:
	gcc/cp         : ChangeLog config-lang.in parser.c 
	gcc/testsuite  : ChangeLog 
Added files:
	gcc/testsuite/g++.dg/parse: comma1.C 

Log message:
	PR c++/14278
	* parser.c (cp_parser_parameter_declaration_list): Commit
	to fewer tentative parses.
	
	PR c++/14278
	* g++.dg/parse/comma1.C: New test.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&r1=1.3972&r2=1.3973
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/config-lang.in.diff?cvsroot=gcc&r1=1.20&r2=1.21
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/parser.c.diff?cvsroot=gcc&r1=1.174&r2=1.175
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.3545&r2=1.3546
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/parse/comma1.C.diff?cvsroot=gcc&r1=1.1&r2=1.2



-- 


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


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

* [Bug c++/14278] [3.4/3.5 Regression] fails when calling through a function pointer
  2004-02-24 18:58 [Bug c++/14278] New: fails when calling through a function pointer jbrandmeyer at earthlink dot net
                   ` (7 preceding siblings ...)
  2004-02-27  0:31 ` cvs-commit at gcc dot gnu dot org
@ 2004-02-27  0:32 ` mmitchel at gcc dot gnu dot org
  8 siblings, 0 replies; 10+ messages in thread
From: mmitchel at gcc dot gnu dot org @ 2004-02-27  0:32 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From mmitchel at gcc dot gnu dot org  2004-02-27 00:32 -------
Fixed in GCC 3.4.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED


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


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

end of thread, other threads:[~2004-02-27  0:32 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-02-24 18:58 [Bug c++/14278] New: fails when calling through a function pointer jbrandmeyer at earthlink dot net
2004-02-24 19:15 ` [Bug c++/14278] [3.4/3.5 Regression] " pinskia at gcc dot gnu dot org
2004-02-24 20:15 ` bangerth at dealii dot org
2004-02-24 20:20 ` bangerth at dealii dot org
2004-02-26 18:07 ` giovannibajo at libero dot it
2004-02-26 19:30 ` bangerth at dealii dot org
2004-02-26 19:59 ` giovannibajo at libero dot it
2004-02-27  0:30 ` cvs-commit at gcc dot gnu dot org
2004-02-27  0:31 ` cvs-commit at gcc dot gnu dot org
2004-02-27  0:32 ` mmitchel 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).