The executable files that
gcc creates have execution permissions
which are different than the permissions that the source file has.
gcc set these permissions ?
Four things intervene to determine the permission of a file.
Some popular choices of permission sets for step 1 are:
It's the umask that causes files not to be world-readable even though applications can and usually do include the others-write permission in the file creation permissions.
In the case of gcc, the output file is first created with permissions 666 (masked by the umask), then later chmod'ed to make it executable. Gcc could create an executable directly, but doesn't: it only makes the file executable when it's finished writing it, so that you don't risk starting to execute the program while it's incomplete.
I'm not positive what you're asking; you mean how does it have permission to set them? A file's owner can set the permissions to whatever they want.
As @AshRj's comment above says, this depends on the default permissions the account has set. Essentially what is done is to start with all permissions (that includes, specifically,