[Bug c++/49921] New: Segfault during compilation, decltype and operator->*

2011-07-31 Thread fabian.bergmark at gmail dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49921

   Summary: Segfault during compilation, decltype and operator->*
   Product: gcc
   Version: 4.5.2
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
AssignedTo: unassig...@gcc.gnu.org
ReportedBy: fabian.bergm...@gmail.com


Code:

#include 

class Local
{
public:
void func() {};
};

int main()
{
Local* l = new Local;
void(Local::*ptr)();
ptr = &Local::func;
decltype((l->*ptr)) i;
std::cerr << typeid(i).name << std::endl;
}

Output:

gcc test.cpp -o test -std=c++0x
test.cpp: In function ‘int main()’:
test.cpp:15:22: internal compiler error: Segmenteringsfel
Please submit a full bug report,
with preprocessed source if appropriate.
See  for instructions.


[Bug c++/49921] Segfault during compilation, decltype and operator->*

2011-07-31 Thread fabian.bergmark at gmail dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49921

fabian.bergmark at gmail dot com changed:

   What|Removed |Added

   Severity|normal  |blocker


[Bug c++/49921] [C++0x] Segfault during compilation, decltype and operator->*

2011-07-31 Thread fabian.bergmark at gmail dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49921

--- Comment #2 from fabian.bergmark at gmail dot com 2011-07-31 10:57:17 UTC ---
(In reply to comment #1)
> Confirmed. Mainline says:
> 
> 49921.C: In function ‘int main()’:
> 49921.C:15:25: internal compiler error: tree check: expected record_type or
> union_type or qual_union_type, have translation_unit_decl in
> maybe_dummy_object, at cp/tree.c:2474

To quote Modern C++ Design by Andrei Alexandrescu:

"In C++, where every object has a type, the result of operator->* or operator.*
is a unique exception."

and

"Both are binary functions all right, and they return something to which you
can apply the function-call operator immediately, but that "something" does no
have a type."

Is this possibly the reason to the error?


[Bug c++/50013] New: Internal compiler error: Error reporting routines re-entered using decltype

2011-08-07 Thread fabian.bergmark at gmail dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50013

   Summary: Internal compiler error: Error reporting routines
re-entered using decltype
   Product: gcc
   Version: 4.5.2
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
AssignedTo: unassig...@gcc.gnu.org
ReportedBy: fabian.bergm...@gmail.com


namespace functor
{
template 
class Functor
{
public:
virtual ret exec(fparam,param...) = 0;
};

template
class Functor
{
public:
virtual ret exec(void) = 0;
};

template 
class Function : public Functor
{
public:
Function(ret(type::*f)(fparam,param...),type* t) : obj(t), func(f)
{
}

virtual ret exec(fparam fp,param... p)
{
return (obj->*func)(fp, p...);
}

protected:
type* obj;
ret(type::*func)(fparam,param...);
};

template
class Function  : public Functor
{
public:
template
class Default;
public:
Function(ret(type::*f)(void), type* t) : obj(t), func(f)
{
}

virtual ret exec()
{
return (obj->*func)();
}
protected:
type* obj;
ret(type::*func)(void);
};

template
template
class Function::Default : public Functor, public Function
{
public:
Default(decltype(Function::func) f, type* t,
fdefault fd) : Function(f, t), save(fd)
{

}

virtual ret exec()
{
return (obj->*func)(save);
}
protected:
fdefault save;
};
}

class Test
{
public:
void test(int) {};
};

int main()
{
Test test;
functor::Function::Default(&Test::test, &test, 10);
}

fabian@ubuntu:~$ g++ test.cpp -o test -std=c++0x
test.cpp: In instantiation of ‘functor::Function::Default’:
test.cpp:83:72:   instantiated from here
test.cpp:32:36: error: ‘void (Test::* functor::Function::func)(int)’ is protected
test.cpp:60:4: error: within this context
test.cpp:32:36: error: ‘void (Test::* functor::Function::func)(int)’ is protected
test.cpp:60:58: error: within this context

Internal compiler error: Error reporting routines re-entered.
Please submit a full bug report,
with preprocessed source if appropriate.
See  for instructions.

If someone could explain if test.cpp:60 really is an error and if so, how to do
it instead, I would be very grateful.