[Bug c++/56658] New: Silent conversion between 'char' and 'int' even though there are 'signed char' and 'unsigned char' alternatives
greenscape777 at gmail dot com
gcc-bugzilla@gcc.gnu.org
Wed Mar 20 07:15:00 GMT 2013
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56658
Bug #: 56658
Summary: Silent conversion between 'char' and 'int' even though
there are 'signed char' and 'unsigned char'
alternatives
Classification: Unclassified
Product: gcc
Version: 4.7.2
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: greenscape777@gmail.com
Consider code snippet:
#include <stdio.h>
typedef signed char int8_t;
typedef unsigned char uint8_t;
void foo(int8_t x)
{
printf("Cartman");
}
void foo(uint8_t x)
{
printf("Stan");
}
void foo(int x)
{
printf("Kenny");
}
int main(int argc, char ** argv)
{
char person = '?';
printf("Oh my God they killed ");
foo(person);
printf("! You bastards!\n");
}
It does compile and generate 0 warnings. Yes, we all know how 'wise' was former
creators of the standard when it came to char. But in this case, if compiler
can't figure out 'char' is 'signed char' there is still an ambiguity. And
silent conversion of 'char' to 'int' is just wrong. As far as I can judge,
clang guys just pathetically copy-pasted GCC's behavior. What I ask for is at
least warning message there.
More information about the Gcc-bugs
mailing list