https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93589
--- Comment #2 from Lokesh Janghel <lokeshjanghel91 at gmail dot com> --- >Note your example code does not match the warning message you have in comment >#0. Sorry, I used some reduce test case. here is the correct one: $ g++ -Wconversion test.cpp test.cpp: In instantiation of ‘void print_byte_order(T) [with T = short int]’: test.cpp:12:28: required from here test.cpp:7:8: warning: conversion to ‘short int’ from ‘int’ may alter its value [-Wconversion] val |= (CHAR_BIT * static_cast<T>(i)) << (CHAR_BIT * static_cast<T>(i)); ^ >Does clang warn even in a non-template case? I reduce the test case for non-template: #define CHAR_BIT 8 void print_byte_order( short ) { short val = 0; unsigned i = 1; val |= (CHAR_BIT * static_cast<short>(i)) << (CHAR_BIT * static_cast<short>(i)); } That gives warning in GCC but Clang not.