stdcxx-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Martin Sebor <se...@roguewave.com>
Subject Re: svn commit: r675044 - in /stdcxx/branches/4.3.x: include/rw/_tuple.h include/tuple tests/utilities/20.tuple.cnstr.cpp tests/utilities/20.tuple.creation.cpp tests/utilities/20.tuple.h tests/utilities/20.tuple.helpers.cpp
Date Wed, 09 Jul 2008 19:08:57 GMT
Eric Lemings wrote:
>  
> 
>> -----Original Message-----
>> From: Travis Vitek [mailto:Travis.Vitek@roguewave.com] 
>> Sent: Wednesday, July 09, 2008 12:28 PM
>> To: dev@stdcxx.apache.org
>> Subject: RE: svn commit: r675044 - in /stdcxx/branches/4.3.x: 
>> include/rw/_tuple.h include/tuple 
>> tests/utilities/20.tuple.cnstr.cpp 
>> tests/utilities/20.tuple.creation.cpp 
>> tests/utilities/20.tuple.h tests/utilities/20.tuple.helpers.cpp
>>
>>  
>>
>> Eric Lemings wrote:
>>>> Travis Vitek wrote:
>>>>
>>>>> Modified: 
>>> stdcxx/branches/4.3.x/tests/utilities/20.tuple.creation.cpp
>>> ...
>>>>> +    rw_assert (0 == std::strcmp (s, "string"), __FILE__, 
>> __LINE__,
>>>>> +               "s == \"string\", got false, expected true");
>>>> The tuple is holding the original pointer (not a copy), so I 
>>> think you
>>>> can check the actual pointer here.
>>> True.  But if that assumption became invalid for whatever reason, the
>>> code above would still work.
>>>
>>> Assumptions are bad.  Robustness is good.  :)
>> As I see it, the tuple implementation is required to hold a copy of an
>> object of the specified type (const char* in this case). If you don't
>> verify the value held is indeed a copy, you are not actually verifying
>> the requirements. This is wrong, and wrong is much worse than bad. :)
> 
> Question:
> 
> const char* s1 = "string";
> const char* s2 = "string";
> // s1 guaranteed to equal s2?

It's unspecified. The compiler is allowed to merge strings.
It's allowed to even go as far as to point s2 at (s1 + 1)
in the snippet below:

     const char* s1 = "Xstring";
     const char* s2 = "string";

Martin


Mime
View raw message