[coding] Removed all build errors and warnings but 3

I got annoyed with all the warnings that pop up while building so I tried to remove them.
There are 3 strict aliasing warnings left which I can not resolve.

So maybe one of you other programmer could point me in the right direction? (Rudeog? pld?)

I understand the general concep of aliasing, but why is
power.d32 = USB_OTG_READ_REG32(&pdev->regs.PCGCCTL);
breaking those rules? All involved types are uint32.

Comments

  • ok. I think it is due to PCGCCTL being a pointer.
    but doesn't this make the code wrong in the first place?
  • edited May 2014
    hmmm found this
    https://github.com/micropython/micropython/issues/211

    the proposed fix resolves the issue.

  • Excellent... I meant to take a look at the warnings, but ran out of time...
    IIRC some gcc versions were broken regarding aliasing warnings, but it looks like the warning was warranted in this case though...
  • @Julian, Most GCC warnings can be removed. The only ones I was not able to remove were related to type or signed/unsigned conversion when using += or &=. There doesn't appear to be an elegant way of getting rid of these (unless someone else can think of something), which is why I created the DISABLE_CONV_WARNING and END_DISABLE_CONV_WARNING macros. It looks like you were able to get these to now work with your version of GCC, so that is good.

  • I resolved to using x = x + 1; to get rid of the warnings.
    I think there is no other way due to automatic integer promotion.

  • Nice work Julian, makes it a lot cleaner for people coming through later.
Sign In or Register to comment.