C++ basic type demotion when returning from a function -


i'm getting (expected)

warning: large integer implicitly truncated unsigned type [-woverflow]

on get2() on not on get1(). i'm quite puzzled why:

#include <stdint.h>  uint8_t get1() {       return uint8_t(uint64_t(10000)); }  uint8_t get2() {      return uint64_t(10000); }  int main() {      return 0; } 

this simplified version of templated code doing other things - without hard-coded values. same happens in c++ when compiled either gcc or clang.

the warning, is reported on get2 function, there because there's implicit conversion (as opposed explicit 1 have on get1) happening, , compiler warning integer being truncated.

the explicit 1 not being reported, because have explicitly told compiler performing truncation, warning redundant in case.


Comments

Popular posts from this blog

powershell Start-Process exit code -1073741502 when used with Credential from a windows service environment -

twig - Using Twigbridge in a Laravel 5.1 Package -

c# - LINQ join Entities from HashSet's, Join vs Dictionary vs HashSet performance -