bug-gplusplus
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Bug report


From: Kavita, Subramanian
Subject: Bug report
Date: Mon, 30 Apr 2001 11:08:33 +0530

Here's the code I tried to compile using gcc and it reports an "Internal
compiler error : 92"
This makes use of member-function templates.

// nullclass.h 
// ----------------
class NullClass {

  public :

    // Null pointer to non-member 
    template <class T>
    operator T* () { return 0; }

    // member-pointer
    template<class C, class T>
    operator T C :: *() { return 0; }

    // Disallow use of & operator

  private :
    void operator & () const;
 
} Null;


// nullclstest.cpp - testdriver that makes use of the NullClass
//
--------------------------------------------------------------------------------
-----

#include <cstdio>
#include <string>

#include "nullclass.h"

using namespace std;

void func(int number) {
  
  printf("Called func(int) ...\n");
  printf("number = %d\n\n", number);
}

void func(string *pstr) {
  
  printf("Called func(string *) ...\n");
  if (pstr)
    printf("String = %s\n\n", pstr->c_str());

}

int main() {

  printf("Calling func(10) ... \n");
  func(10);

  string str = "God is now here";
  printf("Calling func(string *) ... \n");
  func(&str);
  
  printf("Calling func(0) ... \n");  
  func(0);

  printf("Calling func(static_cast<string *>(0)) ... \n");
  func(static_cast<string *>(0));
  
  // This is the one that is actually causing the error.
  printf("Calling func(Null) ... \n");  
  func(Null);  

  return 0;

}

Can anyone please clarify ?

Thanks,
Kavita.
 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]