Email or username:

Password:

Forgot your password?
Top-level
DrYak

@aburka ...Running it, printf will attempt to find a format string at location 72 of the memory. And crash.

There are helpers in GCC for printf, but currently they only check if *the static string* is a proper format and match the argument. They currently cannot check that the wrong type (a character instead of a string) was provided.
C++ is more peeky about types and would probably complain about not converting int to pointer, but still no explanation why 'H' is considered int.

2 comments
DrYak

@dryak that would require an intimate knowledge of the C language and its typing system (not trivial depending on one's background).
It's mostly a leak abstraction if the underneath machine code.

And a complete overhaul of how C is parsed in order to carry over the necessary extra information about type to detect this.

BUT!...

DrYak

@dryak ...BUT a proper linter should immediately spot the problem:

There are way too many stuff between the single quotes in the source code for a proper character.
Are you sure you really want a char/an int8/an integet? Didn't you mean a string instead and forgot the double quotes?

Go Up