This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: While compiling binutils-2.17, i get the error "dereferencing type-punned pointer will break strict-aliasing rules"


Hi Nick

Thanks for the reply. This does seem to be a better way for passing this pointer. The code is not in the gnu sources but some changes that I was trying on my own while porting binutils2.17 to interix.

Thanks
Mayank


-----Original Message-----
From: binutils-owner@sourceware.org [mailto:binutils-owner@sourceware.org] On Behalf Of Nick Clifton
Sent: Tuesday, June 19, 2007 4:32 PM
To: Mayank Kumar
Cc: binutils@sources.redhat.com
Subject: Re: While compiling binutils-2.17, i get the error "dereferencing type-punned pointer will break strict-aliasing rules"

Hi Mayank,

> My issue is that due to this warning I cannot compile with -Werror flag. Is there a way to suppress this particular warning using #pragma etc for this particular case. I don't want to remove -Werror and compile which looks like my last option as of now.


Sorry - I misread your email.

Where (in the sources) is this code that is triggering the error ?

>> (struct bfd_link_hash_entry **) &h))) -->The error points to this line in all places.

In theory the way to solve this problem is to extract the address of the
root field of the coff_link_hash_entry structure and then pass this in
to the call to bfd_coff_link_add_one_symbol.  ie:

   bfd_link_hash_entry * ptr = & h->root;

   ...

   bfd_coff_link_add_one_symbol
        (info, dynobj,
         &LOADER_SYM[bfd_get_symbol_leading_char(dynobj)=='_'?0:1],
         BSF_GLOBAL, s,
         (bfd_vma) 0, (const char *) NULL,
         FALSE, FALSE,
         &ptr)

It would probably be wise to add an assert afterwards to make sure that
the pointer has not changed:

   BFD_ASSERT (ptr == & h->root);


Cheers
   Nick


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]