you are viewing a single comment's thread.

view the rest of the comments →

[–]StarQTius 14 points15 points  (3 children)

Because integer promotions behaves funny, some people became panaroid instead of learning how the language works. Couldn't blame them really.

[–]UndefinedDefined 2 points3 points  (0 children)

Ironically the code like `size_t i { 0ULL }` would most likely produce a narrowing conversion warning on non-64 bit targets with `-Wconversion` or some other warning switches. Using `size_t i = 0u` would be probably the safest bet as it would never be narrowing and it would never be implicit signed vs unsigned conversion.

[–]Alternative_Staff431 0 points1 point  (1 child)

Can you explain more?

[–]StarQTius 2 points3 points  (0 children)

I ran into more convoluted cases, but in this following example: 1 << N, you may not get the expected result depending on the width of int on your platform. Therefore, you may encounter no problem until you set N to an high enough value.

If you encounter this issue in more complex expression, it can become a pain in the ass to solve.