This is an unofficial snapshot of the ISO/IEC JTC1 SC22 WG21 Core Issues List revision 114b. See for the official list.


675. Signedness of bit-field with typedef or template parameter type

Section: 11.4.10  [class.bit]     Status: CD3     Submitter: Richard Corden     Date: 11 February, 2008

[Moved to DR at the October, 2012 meeting.]

Is the signedness of x in the following example implementation-defined?

    template <typename T> struct A {
        T x : 7;

    template struct A<long>;

A similar example could be created with a typedef.

Lawrence Crowl: According to 11.4.10 [class.bit] paragraph 3,

It is implementation-defined whether a plain (neither explicitly signed nor unsigned) char, short, int or long bit-field is signed or unsigned.

This clause is conspicuously silent on typedefs and template parameters.

Clark Nelson: At least in C, the intention is that the presence or absence of this redundant keyword is supposed to be remembered through typedef declarations. I don't remember discussing it in C++, but I would certainly hope that we don't want to do something different. And presumably, we would want template type parameters to work the same way.

So going back to the original example, in an instantiation of A<long>, the signedness of the bit-field is implementation-defined, but in an instantiation of A<signed long>, the bit-field is definitely signed.

Peter Dimov: How can this work? Aren't A<long> and A<signed long> the same type?

(See also issue 739.)

Proposed resolution (February, 2012):

This issue is resolved by the resolution of issue 739.