incubator-stdcxx-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Eric Lemings" <Eric.Lemi...@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:04:43 GMT
 

> -----Original Message-----
> From: Eric Lemings [mailto:Eric.Lemings@roguewave.com] 
> Sent: Wednesday, July 09, 2008 12:40 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
> 
>  
...
> > 
> > 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?

With the following change:

	Index:
/work/stdcxx/branches/4.3.x/tests/utilities/20.tuple.cnstr.cpp
	
===================================================================
	---
/work/stdcxx/branches/4.3.x/tests/utilities/20.tuple.cnstr.cpp
(revision 675050)
	+++
/work/stdcxx/branches/4.3.x/tests/utilities/20.tuple.cnstr.cpp
(working copy)
	@@ -74,18 +73,20 @@
	
	
	 #define LONG_VALUE      INT_VALUE
	-#define STRING_VALUE    "string"
	+#define STRING_VALUE    str_value
	
	+static const char* str_value = "string";
	+
	 static void
	 verify_tuple (const PairTuple& pt)
	 {
	     rw_assert (std::get<0> (pt) == LONG_VALUE, __FILE__,
__LINE__,
	                "std::get<0> (pt), got %d, expected %d",
	                std::get<0> (pt), LONG_VALUE);
	-    rw_assert (0 == std::strcmp (std::get<1> (pt),
STRING_VALUE),
	-               __FILE__, __LINE__,
	-               "std::get<1> (pt), got %s, expected %s",
	-               std::get<1> (pt), STRING_VALUE);
	+    rw_assert (std::get<1> (pt) == STRING_VALUE, __FILE__,
__LINE__,
	+               "std::get<1> (pt), got %p \"%s\", expected %p
\"%s\"",
	+               std::get<1> (pt), std::get<1> (pt),
	+               STRING_VALUE, STRING_VALUE);
	 }

I get the following assertions:

	...
	# ASSERTION (S7) (5 lines):
	# TEXT: std::get<1> (pt), got 000000000f18d8c0 "string",
expected 000000000042796e "string"
	# CLAUSE: [tuple.cnstr]
	# FILE: 20.tuple.cnstr.cpp
	# LINE: 86

	# INFO (S1) (5 lines):
	# TEXT: move constructor (heterogenous tuples)
	# CLAUSE: [tuple.cnstr]
	# FILE: 20.tuple.cnstr.cpp
	# LINE: 458

	# ASSERTION (S7) (5 lines):
	# TEXT: std::get<1> (pt), got 000000000f18d8c0 "string",
expected 000000000042796e "string"
	# CLAUSE: [tuple.cnstr]
	# FILE: 20.tuple.cnstr.cpp
	# LINE: 86

	# INFO (S1) (5 lines):
	# TEXT: copy assignment operator (heterogenous tuples)
	# CLAUSE: [tuple.cnstr]
	# FILE: 20.tuple.cnstr.cpp
	# LINE: 480

	# ASSERTION (S7) (5 lines):
	# TEXT: std::get<1> (pt), got 000000000f18d8c0 "string",
expected 000000000042796e "string"
	# CLAUSE: [tuple.cnstr]
	# FILE: 20.tuple.cnstr.cpp
	# LINE: 86

	# INFO (S1) (5 lines):
	# TEXT: move assignment operator (heterogenous tuples)
	# CLAUSE: [tuple.cnstr]
	# FILE: 20.tuple.cnstr.cpp
	# LINE: 504

	# ASSERTION (S7) (5 lines):
	# TEXT: std::get<1> (pt), got 000000000f18d8c0 "string",
expected 000000000042796e "string"
	# CLAUSE: [tuple.cnstr]
	# FILE: 20.tuple.cnstr.cpp
	# LINE: 86
	...

It appears that pointer values are not guaranteed to be equal when
converting between pointer types.

Brad.

Mime
View raw message