Why does the compiler allow initializing a variable with itself? [duplicate]

I don’t see why it wouldn’t compile. Definition happens prior to initialization. Of course this initialization is pointless, however, there’s no reason it wouldn’t work from the compilers stand point.

C does not have the same types of protections that more modern languages like C# have. The C# compiler would give an error that you’re using an unassigned variable. C doesn’t care. It will not protect you from yourself.

Leave a Comment