Bug 54032 - The C compiler does not warn about casts to more aligned types
Summary: The C compiler does not warn about casts to more aligned types
Status: RESOLVED DUPLICATE of bug 41809
Alias: None
Product: gcc
Classification: Unclassified
Component: c (show other bugs)
Version: 4.8.0
: P3 enhancement
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: diagnostic
Depends on:
Blocks:
 
Reported: 2012-07-19 13:22 UTC by Richard Biener
Modified: 2017-03-24 20:05 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 Richard Biener 2012-07-19 13:22:33 UTC
struct Foo
{
  char c;
  int i;
} __attribute__((packed));

int *foo(struct Foo *p)
{
  return &p->i;
}

does not warn with -W -Wall -Wcast-align.
Comment 1 Andrew Pinski 2012-07-19 21:43:41 UTC
It does warn on STRICT_ALIGN targets though.
Comment 2 Eric Gallager 2017-03-24 17:28:00 UTC
This could probably also be marked as a duplicate of bug 41809 (like bug 79918 was) since that one is older and it looks like the same issue.
Comment 3 Martin Sebor 2017-03-24 20:05:25 UTC
Agreed, thanks.

Note that GCC does not warn on this code on STRICT_ALIGNMENT targets (such as arm-linux-gnueabi.)

*** This bug has been marked as a duplicate of bug 41809 ***