incubator-stdcxx-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Travis Vitek" <Travis.Vi...@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 21:19:37 GMT
 

Martin Sebor wrote:
>
>Eric Lemings wrote:
>>  
>> 
>>> Travis Vitek wrote:
>>>  
>>>
>>> Eric Lemings wrote:
>>>>> Travis Vitek wrote:
>>>>>
>>>>> 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";
>

Just so we're clear, the case that should be happening with tuple is the
following...

  const char* s1 = "string";
  const char* s2 (s1);

  assert (s1 == s2);

The following code works just fine with both the gnu tuple
implementation and ours. I'm not sure why the Brad is seeing the
assertion failure.

  $ cat t.cpp && g++ -std=gnu++0x t.cpp && ./a.out && echo good
  #include <tuple>
  #include <assert.h>

  static const char* s = "hello world";

  int main ()
  {
    const std::tuple<const char*> t (s);
    assert (std::get<0>(t) == s);

    return 0;
  }
  $ good

  $ gmake t && ./t && echo good
  gcc -c -I/amd/devco/vitek/stdcxx/4.3.x/include/ansi -D_RWSTDDEBUG
-D_RWSTD_EXT_CXX_0X -I/amd/devco/vitek/stdcxx/4.3.x/include
-I/build/vitek/4.3.0/11S/include
-I/amd/devco/vitek/stdcxx/4.3.x/tests/include -pedantic -nostdinc++ -g
-std=gnu++0x -W -Wall -Wcast-qual -Winline -Wshadow -Wwrite-strings
-Wno-long-long -Wcast-align -Wno-empty-body -Wno-parentheses t.cpp
  gcc t.o -o t -L/build/vitek/4.3.0/11S/rwtest -lrwtest11S
-L/build/vitek/4.3.0/11S/lib -lstd11S -lsupc++ -lm
  good

>Martin
>
>

Mime
View raw message