Bug 25954 - external variable address assumed not to be zero
Summary: external variable address assumed not to be zero
Status: RESOLVED INVALID
Alias: None
Product: gcc
Classification: Unclassified
Component: c (show other bugs)
Version: 4.0.2
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-01-25 06:16 UTC by frederic.petrot
Modified: 2006-01-25 10:46 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description frederic.petrot 2006-01-25 06:16:44 UTC
Tested on gcc 4.0.2 20050808 and gcc 4.0.3 20051013 

I don't know if this is a bug or a feature : this code, also
compiled without optimization, doesn't check if the address of
the variable is zero.

extern unsigned long int __spm_addr;
int main(void)
{
     return &__spm_addr ? __spm_addr + 1 : -1;
}

gcc 3.x checks the variable address.
Comment 1 Richard Biener 2006-01-25 10:46:41 UTC
The address of the variable cannot be zero.  If you want to play some dynamic loading trick you have to mark the symbol weak.