Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

is `uintXX_t` guaranteed to be the unsigned type of `intXX_t`

is it a guaranteed by the standard that this is true?

Like if for example I am using windows, int and long have same size will it be guaranteed that if int32_t is for example an alias to a signed int it is guaranteed that uint32_t is an alias to unsigned int and not unsigned long.

I need this to avoid UB while type aliasing.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

is uintXX_t guaranteed to be the unsigned type of intXX_t

No.

is it a guranteed by the standard that this is true.

No.

If you find an implemetation where this is not true, I hope someone from the forum gives you a beer. DeathStation 9000 doesn’t count, please do not run your code on it.

I need this to avoid UB while type aliasing.

Just write an assertion to fail the compilation and write your software assuming it’s true.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading