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++/26496] New: Pointer to virtual member function.


The following code snipped causes an internal compiler error:

===
#include <algorithm>
#include <iostream>
#include <iterator>
#include <memory>
#include <string>

using namespace std;

class Distribution {
public:
  Distribution() { }

  virtual ~Distribution() { }

  virtual double sample();
};

double
Distribution::sample() 
{
   return rand();
}

typedef double (Distribution::* Pstd_mem)();

int
main()
{
   Distribution* rng(new Distribution());

   Pstd_mem ptr = &Distribution::sample;

   cout << (rng->*ptr)() << endl; // works

   generate_n(ostream_iterator<double>(cout, "\n"), 100,  mem_fun(rng->*ptr));
// BUG

   return 0;
}
===

Best wishes,

  Matthias


-- 
           Summary: Pointer to virtual member function.
           Product: gcc
           Version: 4.0.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: dwoovseesp at kriocoucke dot mailexpire dot com


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


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