<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/67620>67620</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Missing -Walign-mismatch warning for const parameters
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
tavianator
</td>
</tr>
</table>
<pre>
The following code
```c
#include <stdalign.h>
struct foo {
int array[4];
};
typedef __attribute__((aligned(16))) struct foo foo16;
void bar(foo16 *foo);
void baz(const foo16 *foo);
void qux(struct foo *foo) {
bar(foo);
baz(foo);
}
```
gets a warning for `bar()`, but not `baz()`, with Clang 16.0.6:
```console
$ clang -c foo.c
foo.c:13:9: warning: passing 4-byte aligned argument to 16-byte aligned parameter 1 of 'bar' may result in an unaligned pointer access [-Walign-mismatch]
bar(foo);
^
1 warning generated.
$ clang --version
clang version 16.0.6
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJx0VMuOrDYQ_ZpiUwKBzXPBomc6LWWR3ZWybBkowJGxO7aZmb5fH_HoDtPJRZYxPvVwnTpYOCcHTVRD9gbZORCzH42tvfiQQgtvbNCY7l7_GAl7o5T5lHrA1nQE8Rni0z7n8Tba_ZtxqVs1d4TA353vhJKDjkbgvx3dnLdz67E3BqF42_YQEaX2KKwVd8jeUsjOwHcQisN6nf39Rh31eL0K761sZk_XK7ASWLnmpA5YmeTAqm3gIWdvTJK_xPswssNGWGDlCiOwU2_M4vww3E1-Aitbo53HXxkezP-ev4CVx3of1ofKn2mPQRY-tmSv0YvzC_nHrAN5hwI_hdVLw3pjEfJ4y7BEyWNg79jMHrXxG_TzG_Qp_YjvSugBkzyKoxz46f9bbrQz6iEHlmK7OoXtUme0C2Jb8lPCgZ8q4KfHyZblbdGgHjANm7sn3PuGwg7zRNqjN5jk37GbsGIiTxYTND0CK9bSCpzEHS25WXmUGoXGWT99jNSLh2hbcg4hewv_XLFwkm4Svh0XqR1I_0U3lgeyXcjJk-KBNFnhqYv-Q0X4QdZJozdg29y3HuSuyA9hB_ILJV9lfs3T8NaGSur5Kxz0vJuMlkSHk-lIrdwZJ7826HftvFCKurO0CwTsMjsL7NJI_dKzoKt5V_FKBFQneZWVWVGmcTDWXdolTSaqvG9ELNqy6buqqKqmz8o2zRsRyJrFjMcVKxjnRVJFLOcxF5koOE9j6gnSmCYhVaTUxxQZOwTSuZnqvMhZHCjRkHLrXcOYpk9cQWBsuXpsvfiEzTw4SGMlnXf_RvHSK6r_kJtUXjv3TejbX_mUiAtmq-rR-5tbNMwuwC6D9OPcRK2ZgF2WHPsrvFnzF7Ue2GU9mQN2WU_-TwAAAP__MuGHcA">