Overloaded functions in C ++ work because the compiler encodes each unique method and list of parameter combinations into a unique name for the linker. This coding process is called mangling, and the reverse is demangling.
But in C. there is no such thing. When the compiler encounters a character (either the name of a variable or the name of a function) that is not defined in the current module, it assumes that it is defined in some other module, generates a linker character to write to the table and leaves it for the linker. Here we do not check the parameters.
And also, if there is no type conversion here. You basically send the value to foo. Here it is the assembler code:
movl $65, (%esp) call foo
And foo reads it, removing it from the stack. Since this input value is defined as char, it stores the input value in the al register (one byte):
movb %al, -4(%ebp)
So, for given input data exceeding 256, you will see the variable a in foo, circulating 256 each.
About your second question. In C characters, for initialized variables and functions are defined as strong and multiple strong characters are not allowed, but I'm not sure if this deals with C ++ or not.
source share