stdcxx-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Martin Sebor <>
Subject Re: svn commit: r577002 - /incubator/stdcxx/trunk/tests/utilities/20.temp.buffer.cpp
Date Tue, 18 Sep 2007 19:38:53 GMT
Farid Zaripov wrote:
>> -----Original Message-----
>> From: Martin Sebor [] 
>> Sent: Tuesday, September 18, 2007 9:53 PM
>> To:
>> 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.


> 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.

View raw message