Sujet : Re: constexpr keyword is unnecessary
De : richard.nospam (at) *nospam* gmail.invalid (Richard Harnden)
Groupes : comp.lang.cDate : 29. Oct 2024, 18:26:08
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <vfr5rg$1ku3s$1@dont-email.me>
References : 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
User-Agent : Mozilla Thunderbird
On 28/10/2024 11:58, Thiago Adams wrote:
For instance,
const unsigned char ch = 1234;
GCC:
warning: unsigned conversion from 'int' to 'unsigned char' changes value from '1234' to '210' [-Woverflow]
The programmer might intend this behavior; in that case, the "alarm" should be acknowledged.
If that is what you want, then why not simply say:
const unsigned char ch = 210;
Or change it to the char to a short (or int, long, etc).
?
It's a good and helpful warning. I cannot see why you'd want to ignore it.
Do you expect to remember that 1234 really equals 210 in five years time?