Re: [Fwd: [ROOT] Difference between CINT and

From: cstrato@EUnet.at
Date: Tue Mar 06 2001 - 20:15:01 MET


Dear Masaharu

Thank you for clarifying this issue. I agree with you that
this is convenient for the user, and it would be nice to have
this feature in C++ compilers, too.

Maybe, such intentional differences could be documented
in a future version of the root manual? This would be
helpful.

Best regards
Christian
----------------------------------
C.h.r.i.s.t.i.a.n  S.t.r.a.t.o.w.a
V.i.e.n.n.a.  A.U.S.T.R.I.A
e-mail: cstrato@EUnet.at

Masaharu Goto wrote:

> Hello Christian,
>
> Thank you for your message.
>
> In fact, this is kind of an intentional difference which
> I thought this would be convenient for a user. Handling
> string in such a way is useful when you want to write a
> real quick script.
>
> Let me clarify each case.
>
> 1)
>   char *vName;
>   switch(vName) { case "name1": ...  }
>
>   This is an illegal C/C++ code. Argument to a switch
>   statement has to be an integer constant. It is possible
>   to detect and reject this case in Cint. I am not sure if
>   I should do this.
>
> 2)
>    if(vName == "name1") { ... }
>
>   This , in fact, is a valid C/C++ code. However, the way
>   a compiler or an interpreter handles string constant may
>   vary the result. Strictly speaknig both g++ and Cint complies
>   with the C/C++ behavior, but the code relies on an unguaranteed
>   behavior of C/C++.
>    Cint maintains a table of string constant. If there apears an
>   identical string constant, it is referenced from the same table
>   location. This guarantees if content of string is the same, we
>   will have same address for that. So,  "name1"=="name1" is true.
>   But for most of the compilers, this is not guaranteed. And C/C++
>   leaves freedom of handling such a case. Some compilers may warn
>   you this ambiguity, some are not.
>
> Thank you
> Masaharu Goto
>



This archive was generated by hypermail 2b29 : Fri Jun 08 2001 - 11:51:20 MEST