On Sun, 2015-09-20 at 08:38AM +0200, Richard Biener wrote:
> On September 20, 2015 1:40:12 AM GMT+02:00, Martin Sebor <mse...@gmail.com> 
> wrote:
> >On 09/19/2015 03:32 PM, Sören Brinkmann wrote:
> >> Hi Andrew,
> >>
> >> On Sat, 2015-09-19 at 11:34AM -0700, pins...@gmail.com wrote:
> >>>
> >>>
> >>>> On Sep 19, 2015, at 11:00 AM, Sören Brinkmann
> ><soren.brinkm...@xilinx.com> wrote:
> >>>>
> >>>> Hi,
> >>>>
> >>>> I recently came across some bug in my program that I could narrow
> >down
> >>>> to the snipped below (also attached with a Makefile).
> >>>>
> >>>>   extern unsigned int _vector_table;
> >>>
> >>> You need the attribute weak here if the location of _vector_table
> >can be a null pointer.
> >>
> >> Indeed, that fixes the problem. Would you have any additional
> >background
> >> why the 'weak' is required in this case? To me it sounded like the
> >> '-fno-delete-null-pointer-checks' should be sufficient.
> >
> >-fno-delete-null-pointer-checks prevents GCC from removing tests
> >for null pointers after such pointers have been dereferenced. For
> >example, in the following function, GCC normally eliminates the
> >second if statement because the first statement lets it assume
> >that p is not null (otherwise dereferencing it would be undefined).
> >
> >   int foo (int *p) {
> >     if (*p == 0) return 0;
> >     if (p == 0) return 1;
> >     return 2;
> >   }
> >
> >The option doesn't affect other assumptions such as that every
> >object and function in a program lives at a valid, non-null
> >address.
> 
> Actually we abuse this flag for exactly this purpose so I think the testcase 
> shows a bug.  Unless the particular target cannot have global vars at address 
> zero.
> 
> Would you mind opening a bugreport?

Not at all. You can find it here:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67651

        Thanks,
        Sören

Reply via email to