[ROOT] RE: combining char*, TCut, and TString (

From: Masaharu Goto (MXJ02154@nifty.ne.jp)
Date: Sat Jun 23 2001 - 17:18:47 MEST


Hello Philippe,

Thank you for reminding me of this problem.
I realized the same problem affects few other bug reports.
This one will be fixed in 5.15.05. 

Masaharu Goto



>Date: Fri, 22 Jun 2001 16:03:43 -0500
>From: Philippe Canal <pcanal@fnal.gov>
>To: Masaharu Goto <MXJ02154@nifty.ne.jp>
>Cc: pcanal@fnal.gov
>Subject: RE: combining char*, TCut, and TString (PR#852)
>
>Hi,
>
>This is a problem in CINT (still present in 5.15.03).
>
>The problem is that CINT does discover that there is a operator char*
>for the class TString and thus knows to allows passing a TString to
>a function expecting a char* [In Stephen cases the function is
>TCut operator&&(const TCut &lhs, const char *rhs) ] 
>
>BUT cint forget to actually call TString::operator char* before passing the
>value down!
>
>A clearer example of this problem is:
>======== Ouput using ROOT with cint 5.15.03 on IRIX 6.5 with gcc v2.95.2
>root [0] .x pb39script.C
>Processing pb39script.C...
>
>
>We created a TString object at 105f0d18 containing the string: "this IS 
mystring"
>but can look like T$Bw?%J(B5$B%j(B
>ReadFromConstCharPtr got the ptr:105f0d18 with is the string "T$Bw?%J(B5$B%j(B"
>But is also the address of the TString containing: "this IS mystring"
>
>======== pb39script.C
>{
>  gROOT->ProcessLine(".L pb39.C+"); // Load compiled version
>
>  TString mystring = "this IS mystring";
>  TString *pointer = & mystring;
>
>  fprintf(stderr,"\n\nWe created a TString object at %p containing the string
: \"%s\"\n",
>          pointer,(char*)mystring);
>  fprintf(stderr,"but can look like %s\n",
>          mystring);
>
>  ReadFromConstCharPtr(mystring);
>
>}
>======== pb39.C
>#include <stdio.h>
>#include "TString.h"
>
>void pb39() {
>
>}
>
>void ReadFromTString(TString& arg) {
>  fprintf(stderr,"address %p\nvalue %p\n",
>          (void*)&arg,(const char*)arg);
>}
>
>void ReadFromConstCharPtr(const char * arg) {
>  fprintf(stderr,"ReadFromConstCharPtr got the ptr:%p with is the string 
\"%s\"\n",
>          arg,arg);
>  fprintf(stderr,"But is also the address of the TString containing: 
\"%s\"\n",
>          ((TString*)(arg))->Data());
> 
>}
>
>Philippe.



This archive was generated by hypermail 2b29 : Tue Jan 01 2002 - 17:50:50 MET