half.h default user-provided constructor breaks c++ semantics (value/zero initialization vs default initialization) #246
Labels
Needs Discussion
To be discussed in the technical steering committee
The user-provided default constructor for
half
inhalf.h
does not respect value/zero initialization which makes the type awkward and/or buggy to work with, especially in generic template code that works with other number types (e.g. floats).Expected behavior (as with float):
Current behavior (half):
Proposed solution (C++11)
In class definition (
half.h
) define the default constructor as an explicitly defaulted one:in order to correctly perform value initialization or default initialization (which actually does nothing). The
unsigned short
member's 0 value coincides with 16-bit floating point value 0. With the proposed solution, we have the same behavior as with floats.The text was updated successfully, but these errors were encountered: