You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@stdcxx.apache.org by Martin Sebor <se...@roguewave.com> on 2008/06/13 14:15:30 UTC

Re: svn commit: r667365 [1/3] - in /stdcxx/branches/4.3.x: etc/config/src/ include/ include/rw/ tests/utilities/

vitek@apache.org wrote:
> Author: vitek
> Date: Thu Jun 12 22:53:51 2008
> New Revision: 667365

I understand that this is work in progress so just to help
make progress here are a few comments on some small issues
with this change:

Some files are missing the required terminating newline (they
are noted in the svn change notification).

Also, some of the #include guards are inconsistent with the
names of the headers they guard after their renaming. The
guards need to be reviewed and bring into harmony with the
names (we night want to write a simple shell script to help
with this process).

Finally, I'm not sure the patch is consistent WRT the use
of the type and value (vs. _C_type and _C_value) typedefs.
I hope we can agree on using of the public names throughout.

> 
> URL: http://svn.apache.org/viewvc?rev=667365&view=rev
> Log:
> 2008-06-12  Travis Vitek  <vi...@roguewave.com>
> 
> 	STDCXX-916
> 	* include/type_traits: New file defines C++0x type traits.
> 	* include/rw/_config-gcc.h: Add macros for compiler support.

The macro names should be listed here so we can find them in
ChangeLogs. I was also hoping we were in agreement on removing
the _TT_ part from the macro names.

> 	* include/rw/_config-msvc.h: Ditto.
> 	* include/rw/_config.h [_RWSTD_EXT_CXX_OX]: Disable C++0x
> 	extensions unless defined.
> 	* include/rw/_defs.h [_RWSTD_SWCHAR_INT_T]: Add new macro that
> 	defines a type that has same size and layout a the fictional
> 	signed wchar_t.

What do we need _RWSTD_SWCHAR_INT_T for?

[...searching...]

I see: for make_signed. Are you sure the traits are correct for
char and wchar_t? Also, do you believe the working draft to be
unambiguous and correct? Based on my reading, make_signed<T>
::type should be the same as T if T is a signed integral type.
IIUC, our make_signed<char>::type is defined to signed char
regardless of the signed-ness of char. Ditto for wchar_t.

Also, I assume the big block of #ifdef'ed out code with the
_RWSTD_TT_XXX() macro definitions was meant to be deleted?

Finally, the (unsafe) change to _RWSTD_UWCHAR_INT_T isn't
mentioned here. It should be reverted (and _RWSTD_SWCHAR_INT_T
should be changed to something like _RWSTD_PTRDIFF_T or maybe
_RWSTD_SSIZE_T.

Martin

Re: svn commit: r667365 [1/3] - in /stdcxx/branches/4.3.x: etc/config/src/ include/ include/rw/ tests/utilities/

Posted by Martin Sebor <se...@roguewave.com>.
Travis Vitek wrote:
>  
> 
> Martin Sebor wrote:
>> Travis Vitek wrote:
>>> Martin Sebor wrote:
>>>
>>>> Are you sure the traits are correct for char and wchar_t?
>>> No.
>>>
>>>> Also, do you believe the working draft to be
>>>> unambiguous and correct?
>>> No. For reference, I've pulled the requirements from the standard and
>>> pasted them below.
>>>
>>> There is at least one obvious ambiguity. Assume that char is signed.
>>> Should std::make_signed<unsigned char>::type be 'char' or 
>> 'signed char'?
>>
>> Yes. This needs to be clarified. Could you bring it up on
>> c++std-lib@accu.org to make sure it's not a known problem
>> that's already being handled? I'll help you write up the
>> issue if it isn't.
> 
> Okay. How formal is this list? Can I just post a quick message showing a
> testcase and asking if the issue is known, or should I go through the
> trouble to pull all of the necessary quotes from the draft, proposal and
> papers?

You don't need to quote the spec like you did here. A small
test case is always nice, although in this case, I'm not sure
it's necessary. All we need to know, I think, is whether
make_signed<T>::type is intended to be signed char or plain
char if T is char and CHAR_MIN < 0, and what the intended
effects are for T being wchar_t. And maybe also for T being
an enumeration.

> 
>>> Same goes for std::make_signed<enum_t>::type when sizeof(enum_t) ==
>>> sizeof(char). If both 'char' and 'signed char' are signed integral
>>> types, which of the two should be used?
>> I didn't think enums could be smaller than int but that's
>> probably going to change with scoped enums.
> 
> If I'm reading the standard correctly, specifically decl.enum p4 and 5,
> it seems that it is allowed.
> 
>>> It also seems wrong to have std::make_signed<char>::type be 'signed
>>> char' only when 'char' is unsigned. It seems that users 
>> would like to be
>>> able to expect that the resulting type be consistent 
>> regardless of the
>>> signed-ness of char.
>> Sounds like a valid point to me. OTOH, the actual type may
>> not matter all that much just as long as the signedness is
>> right. In my experience, in the handful of cases when I've
>> ever needed an unsigned form of a (possibly) signed type
>> all I cared about was the absence of signedness.
>>
> 
> Sure, but it would be nice if there was a requirement.

Absolutely!

Martin

RE: svn commit: r667365 [1/3] - in /stdcxx/branches/4.3.x: etc/config/src/ include/ include/rw/ tests/utilities/

Posted by Travis Vitek <Tr...@roguewave.com>.
 

Martin Sebor wrote:
>
>Travis Vitek wrote:
>> 
>> Martin Sebor wrote:
>> 
>>> Are you sure the traits are correct for char and wchar_t?
>> 
>> No.
>> 
>>> Also, do you believe the working draft to be
>>> unambiguous and correct?
>> 
>> No. For reference, I've pulled the requirements from the standard and
>> pasted them below.
>> 
>> There is at least one obvious ambiguity. Assume that char is signed.
>> Should std::make_signed<unsigned char>::type be 'char' or 
>'signed char'?
>
>Yes. This needs to be clarified. Could you bring it up on
>c++std-lib@accu.org to make sure it's not a known problem
>that's already being handled? I'll help you write up the
>issue if it isn't.

Okay. How formal is this list? Can I just post a quick message showing a
testcase and asking if the issue is known, or should I go through the
trouble to pull all of the necessary quotes from the draft, proposal and
papers?

>
>> Same goes for std::make_signed<enum_t>::type when sizeof(enum_t) ==
>> sizeof(char). If both 'char' and 'signed char' are signed integral
>> types, which of the two should be used?
>
>I didn't think enums could be smaller than int but that's
>probably going to change with scoped enums.

If I'm reading the standard correctly, specifically decl.enum p4 and 5,
it seems that it is allowed.

>> 
>> It also seems wrong to have std::make_signed<char>::type be 'signed
>> char' only when 'char' is unsigned. It seems that users 
>would like to be
>> able to expect that the resulting type be consistent 
>regardless of the
>> signed-ness of char.
>
>Sounds like a valid point to me. OTOH, the actual type may
>not matter all that much just as long as the signedness is
>right. In my experience, in the handful of cases when I've
>ever needed an unsigned form of a (possibly) signed type
>all I cared about was the absence of signedness.
>

Sure, but it would be nice if there was a requirement.

>> 
>> Both of these issues make me think that the definition of make_signed
>> should have said 'signed integer type' instead of 'signed integral
>> type'.
>
>You mean just signed/unsigned integers (I had to look up the
>difference). I suspect most people would find a make_signed
>that didn't work with char to be broken.

Yeah, my proposed change wouldn't be sufficient. It would need to say
something about using explicit signed/unsigned qualifications for char.

>
>> 
>>> Based on my reading, make_signed<T>
>>> ::type should be the same as T if T is a signed integral type.
>>> IIUC, our make_signed<char>::type is defined to signed char
>>> regardless of the signed-ness of char. Ditto for wchar_t.
>
>Right. That's what caught my attention because it goes
>against the requirement.
>
>Martin
>
>>>

Re: svn commit: r667365 [1/3] - in /stdcxx/branches/4.3.x: etc/config/src/ include/ include/rw/ tests/utilities/

Posted by Martin Sebor <se...@roguewave.com>.
Travis Vitek wrote:
>  
> 
> Martin Sebor wrote:
> 
>> Are you sure the traits are correct for char and wchar_t?
> 
> No.
> 
>> Also, do you believe the working draft to be
>> unambiguous and correct?
> 
> No. For reference, I've pulled the requirements from the standard and
> pasted them below.
> 
> There is at least one obvious ambiguity. Assume that char is signed.
> Should std::make_signed<unsigned char>::type be 'char' or 'signed char'?

Yes. This needs to be clarified. Could you bring it up on
c++std-lib@accu.org to make sure it's not a known problem
that's already being handled? I'll help you write up the
issue if it isn't.

> Same goes for std::make_signed<enum_t>::type when sizeof(enum_t) ==
> sizeof(char). If both 'char' and 'signed char' are signed integral
> types, which of the two should be used?

I didn't think enums could be smaller than int but that's
probably going to change with scoped enums.

> 
> It also seems wrong to have std::make_signed<char>::type be 'signed
> char' only when 'char' is unsigned. It seems that users would like to be
> able to expect that the resulting type be consistent regardless of the
> signed-ness of char.

Sounds like a valid point to me. OTOH, the actual type may
not matter all that much just as long as the signedness is
right. In my experience, in the handful of cases when I've
ever needed an unsigned form of a (possibly) signed type
all I cared about was the absence of signedness.

> 
> Both of these issues make me think that the definition of make_signed
> should have said 'signed integer type' instead of 'signed integral
> type'.

You mean just signed/unsigned integers (I had to look up the
difference). I suspect most people would find a make_signed
that didn't work with char to be broken.

> 
>> Based on my reading, make_signed<T>
>> ::type should be the same as T if T is a signed integral type.
>> IIUC, our make_signed<char>::type is defined to signed char
>> regardless of the signed-ness of char. Ditto for wchar_t.

Right. That's what caught my attention because it goes
against the requirement.

Martin

>>
> 
> [basic.fundamental] p2
> 
>   There are five standard signed integer types: "signed char",
>   "short int", "int", "long int", and "long long int". In this
>   list, each type provides at least as much storage as those
>   preceding it in the list. [...] The standard and extended
>   signed integer types are collectively called signed integer
>   types.
> 
> [basic.fundamental] p3
> 
>   For each of the standard signed integer types, there exists
>   a corresponding standard unsigned integer type: "unsigned
>   char", "unsigned short int", "unsigned int", "unsigned long
>   int", and "unsigned long long int", each of which occupies
>   the same amount of storage and has the same alignment
>   requirements as the corresponding signed integer type. [...]
>   The standard and extended unsigned integer types are
>   collectively called unsigned integer types.
> 
> [basic.fundamental] p7
> 
>   Types bool, char, char16_t, char32_t, wchar_t, and the signed
>   and unsigned integer types are collectively called integral
>   types.
> 
> [meta.trans.sign]
> 
>   If T names a (possibly cv-qualified) signed integral type then
>   the member typedef type shall name the type T; otherwise, if T
>   names a (possibly cv-qualified) unsigned integral type then type
>   shall name the corresponding signed integral type, with the same
>   cv-qualifiers as T; otherwise, type shall name the signed
>   integral type with smallest rank for which sizeof(T) ==
>   sizeof(type), with the same cv-qualifiers as T.
> 
> 


RE: svn commit: r667365 [1/3] - in /stdcxx/branches/4.3.x: etc/config/src/ include/ include/rw/ tests/utilities/

Posted by Travis Vitek <Tr...@roguewave.com>.
 

Martin Sebor wrote:

>Are you sure the traits are correct for char and wchar_t?

No.

>Also, do you believe the working draft to be
>unambiguous and correct?

No. For reference, I've pulled the requirements from the standard and
pasted them below.

There is at least one obvious ambiguity. Assume that char is signed.
Should std::make_signed<unsigned char>::type be 'char' or 'signed char'?
Same goes for std::make_signed<enum_t>::type when sizeof(enum_t) ==
sizeof(char). If both 'char' and 'signed char' are signed integral
types, which of the two should be used?

It also seems wrong to have std::make_signed<char>::type be 'signed
char' only when 'char' is unsigned. It seems that users would like to be
able to expect that the resulting type be consistent regardless of the
signed-ness of char.

Both of these issues make me think that the definition of make_signed
should have said 'signed integer type' instead of 'signed integral
type'.

>Based on my reading, make_signed<T>
>::type should be the same as T if T is a signed integral type.
>IIUC, our make_signed<char>::type is defined to signed char
>regardless of the signed-ness of char. Ditto for wchar_t.
>

[basic.fundamental] p2

  There are five standard signed integer types: "signed char",
  "short int", "int", "long int", and "long long int". In this
  list, each type provides at least as much storage as those
  preceding it in the list. [...] The standard and extended
  signed integer types are collectively called signed integer
  types.

[basic.fundamental] p3

  For each of the standard signed integer types, there exists
  a corresponding standard unsigned integer type: "unsigned
  char", "unsigned short int", "unsigned int", "unsigned long
  int", and "unsigned long long int", each of which occupies
  the same amount of storage and has the same alignment
  requirements as the corresponding signed integer type. [...]
  The standard and extended unsigned integer types are
  collectively called unsigned integer types.

[basic.fundamental] p7

  Types bool, char, char16_t, char32_t, wchar_t, and the signed
  and unsigned integer types are collectively called integral
  types.

[meta.trans.sign]

  If T names a (possibly cv-qualified) signed integral type then
  the member typedef type shall name the type T; otherwise, if T
  names a (possibly cv-qualified) unsigned integral type then type
  shall name the corresponding signed integral type, with the same
  cv-qualifiers as T; otherwise, type shall name the signed
  integral type with smallest rank for which sizeof(T) ==
  sizeof(type), with the same cv-qualifiers as T.



RE: svn commit: r667365 [1/3] - in /stdcxx/branches/4.3.x: etc/config/src/ include/ include/rw/ tests/utilities/

Posted by Travis Vitek <Tr...@roguewave.com>.
 

Martin Sebor wrote:
>
>vitek@apache.org wrote:
>> Author: vitek
>> Date: Thu Jun 12 22:53:51 2008
>> New Revision: 667365
>
>I understand that this is work in progress so just to help
>make progress here are a few comments on some small issues
>with this change:
>
>Some files are missing the required terminating newline (they
>are noted in the svn change notification).

Fixed in http://svn.apache.org/viewvc?rev=668208&view=rev.

>Also, some of the #include guards are inconsistent with the
>names of the headers they guard after their renaming. The
>guards need to be reviewed and bring into harmony with the
>names (we night want to write a simple shell script to help
>with this process).

Fixed in http://svn.apache.org/viewvc?rev=668223&view=rev.

>
>Finally, I'm not sure the patch is consistent WRT the use
>of the type and value (vs. _C_type and _C_value) typedefs.
>I hope we can agree on using of the public names throughout.

I opted to use the prefix for helpers that should never be anywhere
except in the implementation of the actual trait. For example,
__rw_add_lvalue_reference_impl<> uses '_C_type' and
__rw_add_lvalue_reference<> uses 'type'.

>
>> 
>> URL: http://svn.apache.org/viewvc?rev=667365&view=rev
>> Log:
>> 2008-06-12  Travis Vitek  <vi...@roguewave.com>
>> 
>> 	STDCXX-916
>> 	* include/type_traits: New file defines C++0x type traits.
>> 	* include/rw/_config-gcc.h: Add macros for compiler support.
>
>The macro names should be listed here so we can find them in
>ChangeLogs.

Log updated.

>I was also hoping we were in agreement on removing
>the _TT_ part from the macro names.

I do recall that you suggested this, but I don't recall agreeing to
this.

One disadvantage of removing them is that the macros are defined in one
file if the trait has compiler support or in another file if it doesn't.
i.e. _RWSTD_IS_ENUM() is defined if you #include rw/_defs.h if compiler
support is available, but it would be defined in rw/_meta_cat.h if it is
not. This could lead to failures because the 'user' forgot to include
the correct header and tested on platforms that had compiler support.

>
>> 	* include/rw/_config-msvc.h: Ditto.
>> 	* include/rw/_config.h [_RWSTD_EXT_CXX_OX]: Disable C++0x
>> 	extensions unless defined.
>> 	* include/rw/_defs.h [_RWSTD_SWCHAR_INT_T]: Add new macro that
>> 	defines a type that has same size and layout a the fictional
>> 	signed wchar_t.
>
>What do we need _RWSTD_SWCHAR_INT_T for?
>
>[...searching...]
>
>I see: for make_signed. Are you sure the traits are correct for
>char and wchar_t? Also, do you believe the working draft to be
>unambiguous and correct? Based on my reading, make_signed<T>
>::type should be the same as T if T is a signed integral type.
>IIUC, our make_signed<char>::type is defined to signed char
>regardless of the signed-ness of char. Ditto for wchar_t.
>
>Also, I assume the big block of #ifdef'ed out code with the
>_RWSTD_TT_XXX() macro definitions was meant to be deleted?
>
>Finally, the (unsafe) change to _RWSTD_UWCHAR_INT_T isn't
>mentioned here.

I'll update the log but I'm unsure exactly why this change is unsafe.

>It should be reverted (and _RWSTD_SWCHAR_INT_T
>should be changed to something like _RWSTD_PTRDIFF_T or maybe
>_RWSTD_SSIZE_T.

I don't understand why this is any better. It would seem that if there
are a finite number of [un]signed integral types and we want a
[un]signed integral type that is the same size as 'wchar_t' we would
just look at the [un]signed integral types. There should be no need to
even consider anything else.

If anything I should have added a #error case if _RWSTD_WCHAR_SIZE is
not equal to the size of at least one of the integral types.

>
>Martin
>