[LC++]Curiosity

Dr Mark H Phillips mark at austrics.com.au
Thu Dec 4 07:06:05 UTC 2003


On Wed, 2003-12-03 at 18:50, Steven Shaw wrote:
> I think it's a compiler bug. I tried the following with g++-2.95 (.4) and it 
> worked (all I did was remove the unneccessary cast):

Yes, I tried to reduce the problem to the simplest program which
still had the bug, and the cast was part of it.  (Previously this
cast was actually a member function call for the operator*, which
was a const member call.)

Cheers,

Mark.

> 
> #include <iostream>
> #include <string>
> #include <utility>
> 
> struct Dequote {
>   std::string operator()(std::string token) const {
>     std::string ret = "";
>     ret+= token[1];
>     return ret;
>   }
> } dequote;
> 
> int main() {
>   std::pair<std::string, int>*
>       lemon(new std::pair<std::string, int>("\"B\"", 99));
> 
>   std::cerr<<"\nlemon = "<<lemon->first<<"\n";
> 
>   std::string ned = dequote(lemon->first);
> 
>   std::cerr<<"\nned = "<<ned<<"\n";
> 
>   std::cerr<<"\nlemon = "<<lemon->first<<".\n";
> 
>   std::cerr<<"\nthe end.\n";
> }
> 
> _______________________________________________
> This is the Linux C++ Programming List
> : http://lists.linux.org.au/listinfo/tuxcpprogramming List




More information about the tuxCPProgramming mailing list