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

gcc - MinGW's ld cannot perform PE operations on non PE output file -

timeout - Handshake_timeout on RabbitMQ using python and pika from remote vm -

c# - Search and Add Comment with OpenXML for Word -