You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stdcxx.apache.org by fa...@apache.org on 2007/09/18 20:01:47 UTC

svn commit: r577002 - /incubator/stdcxx/trunk/tests/utilities/20.temp.buffer.cpp

Author: faridz
Date: Tue Sep 18 11:01:47 2007
New Revision: 577002

URL: http://svn.apache.org/viewvc?rev=577002&view=rev
Log:
2007-09-18 Farid Zaripov <Fa...@epam.com>

	* 20.temp.buffer.cpp (run_test): Use _RWSTD_LONG_MAX instead
	of _RWSTD_PTRDIFF_MAX because BigStruct parametrized by
	unsigned long type and sizeof (_RWSTD_PTRDIFF_T) can be
	greater that sizeof (unsigned long).

Modified:
    incubator/stdcxx/trunk/tests/utilities/20.temp.buffer.cpp

Modified: incubator/stdcxx/trunk/tests/utilities/20.temp.buffer.cpp
URL: http://svn.apache.org/viewvc/incubator/stdcxx/trunk/tests/utilities/20.temp.buffer.cpp?rev=577002&r1=577001&r2=577002&view=diff
==============================================================================
--- incubator/stdcxx/trunk/tests/utilities/20.temp.buffer.cpp (original)
+++ incubator/stdcxx/trunk/tests/utilities/20.temp.buffer.cpp Tue Sep 18 11:01:47 2007
@@ -443,9 +443,9 @@
     // avoid instantiating test on very large structs
     // to prevent failures (at compile or run-time) due
     // to compiler bugs
-    test_failure ((BigStruct<_RWSTD_PTRDIFF_MAX / 2>*)0, 0);
-    test_failure ((BigStruct<_RWSTD_PTRDIFF_MAX - 1>*)0, 0);
-    test_failure ((BigStruct<_RWSTD_PTRDIFF_MAX>*)0, 0);
+    test_failure ((BigStruct<_RWSTD_LONG_MAX / 2>*)0, 0);
+    test_failure ((BigStruct<_RWSTD_LONG_MAX - 1>*)0, 0);
+    test_failure ((BigStruct<_RWSTD_LONG_MAX>*)0, 0);
 
 #else
 



Re: svn commit: r577002 - /incubator/stdcxx/trunk/tests/utilities/20.temp.buffer.cpp

Posted by Martin Sebor <se...@roguewave.com>.
Farid Zaripov wrote:
>> -----Original Message-----
>> From: Martin Sebor [mailto:sebor@roguewave.com] 
>> Sent: Tuesday, September 18, 2007 9:53 PM
>> To: stdcxx-dev@incubator.apache.org
>> Subject: Re: svn commit: r577002 - 
>> /incubator/stdcxx/trunk/tests/utilities/20.temp.buffer.cpp
>>
>>> 	* 20.temp.buffer.cpp (run_test): Use _RWSTD_LONG_MAX instead
>>> 	of _RWSTD_PTRDIFF_MAX because BigStruct parametrized by
>>> 	unsigned long type and sizeof (_RWSTD_PTRDIFF_T) can be
>>> 	greater that sizeof (unsigned long).
>> Shouldn't that be the other way around? I mean, wouldn't a 
>> more robust solution be to parametrize BigStruct on ptrdiff_t 
>> so that it can be instantiated with the largest possible value even on
>> LLP64 like Windows?
> 
>   Are there any LLP64 platforms except Windows?

I don't know of any other platforms with this silly model, but
that doesn't mean there isn't one.

> 
>   Because on Windows the maximum size of the array is 0x7fffffff bytes.

AFAICT, they're within their right to impose a limit. The C++
standard says the maximum size of an object that a conforming
implementation is required to support is 262,144.

We need to avoid exceeding the limit (which doesn't necessarily
mean that we need to use unsigned long, just that we shouldn't
be trying to create bigger objects than what the implementation
allows). It's your call but if I were to decide, I would change
BigStruct to take ptrdiff_t, or better yet, size_t as a parameter,
and instantiate it on a INT_MAX just for Windows, and leave it
the way it was everywhere else.

Martin

> 
> The following line of code:
> 
> char buf [0x80000000];
> 
> inducts the error on MSVC (32 bit and 64 bit):
> 
> error C2148: total size of array must not exceed 0x7fffffff bytes
> 
> on ICC 9.1 (32 bit and 64 bit), 10.0 (32 bit and 64 bit):
> 
> error: array is too large
>   char buf [0x80000000];
>        ^
> 
> Farid.


RE: svn commit: r577002 - /incubator/stdcxx/trunk/tests/utilities/20.temp.buffer.cpp

Posted by Farid Zaripov <Fa...@epam.com>.
> -----Original Message-----
> From: Martin Sebor [mailto:sebor@roguewave.com] 
> Sent: Tuesday, September 18, 2007 9:53 PM
> To: stdcxx-dev@incubator.apache.org
> Subject: Re: svn commit: r577002 - 
> /incubator/stdcxx/trunk/tests/utilities/20.temp.buffer.cpp
> 
> > 	* 20.temp.buffer.cpp (run_test): Use _RWSTD_LONG_MAX instead
> > 	of _RWSTD_PTRDIFF_MAX because BigStruct parametrized by
> > 	unsigned long type and sizeof (_RWSTD_PTRDIFF_T) can be
> > 	greater that sizeof (unsigned long).
> 
> Shouldn't that be the other way around? I mean, wouldn't a 
> more robust solution be to parametrize BigStruct on ptrdiff_t 
> so that it can be instantiated with the largest possible value even on
> LLP64 like Windows?

  Are there any LLP64 platforms except Windows?

  Because on Windows the maximum size of the array is 0x7fffffff bytes.

The following line of code:

char buf [0x80000000];

inducts the error on MSVC (32 bit and 64 bit):

error C2148: total size of array must not exceed 0x7fffffff bytes

on ICC 9.1 (32 bit and 64 bit), 10.0 (32 bit and 64 bit):

error: array is too large
  char buf [0x80000000];
       ^

Farid.

Re: svn commit: r577002 - /incubator/stdcxx/trunk/tests/utilities/20.temp.buffer.cpp

Posted by Martin Sebor <se...@roguewave.com>.
faridz@apache.org wrote:
> Author: faridz
> Date: Tue Sep 18 11:01:47 2007
> New Revision: 577002
> 
> URL: http://svn.apache.org/viewvc?rev=577002&view=rev
> Log:
> 2007-09-18 Farid Zaripov <Fa...@epam.com>
> 
> 	* 20.temp.buffer.cpp (run_test): Use _RWSTD_LONG_MAX instead
> 	of _RWSTD_PTRDIFF_MAX because BigStruct parametrized by
> 	unsigned long type and sizeof (_RWSTD_PTRDIFF_T) can be
> 	greater that sizeof (unsigned long).

Shouldn't that be the other way around? I mean, wouldn't a more
robust solution be to parametrize BigStruct on ptrdiff_t so that
it can be instantiated with the largest possible value even on
LLP64 like Windows?

Martin

> 
> Modified:
>     incubator/stdcxx/trunk/tests/utilities/20.temp.buffer.cpp
> 
> Modified: incubator/stdcxx/trunk/tests/utilities/20.temp.buffer.cpp
> URL: http://svn.apache.org/viewvc/incubator/stdcxx/trunk/tests/utilities/20.temp.buffer.cpp?rev=577002&r1=577001&r2=577002&view=diff
> ==============================================================================
> --- incubator/stdcxx/trunk/tests/utilities/20.temp.buffer.cpp (original)
> +++ incubator/stdcxx/trunk/tests/utilities/20.temp.buffer.cpp Tue Sep 18 11:01:47 2007
> @@ -443,9 +443,9 @@
>      // avoid instantiating test on very large structs
>      // to prevent failures (at compile or run-time) due
>      // to compiler bugs
> -    test_failure ((BigStruct<_RWSTD_PTRDIFF_MAX / 2>*)0, 0);
> -    test_failure ((BigStruct<_RWSTD_PTRDIFF_MAX - 1>*)0, 0);
> -    test_failure ((BigStruct<_RWSTD_PTRDIFF_MAX>*)0, 0);
> +    test_failure ((BigStruct<_RWSTD_LONG_MAX / 2>*)0, 0);
> +    test_failure ((BigStruct<_RWSTD_LONG_MAX - 1>*)0, 0);
> +    test_failure ((BigStruct<_RWSTD_LONG_MAX>*)0, 0);
>  
>  #else
>  
> 
>