<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/62724>62724</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
The compiler is unable to recognize nonnull variable
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
ZijunZhaoCCK
</td>
</tr>
</table>
<pre>
https://android-build.googleplex.com/builds/submitted/10125312/test_suites_x86_64_coverage/latest/view/logs/build_error.log?legacy
```
packages/modules/DnsResolver/tests/resolv_test_utils.cpp:69:40: error: implicit conversion from nullable pointer 'char * _Nullable' to non-nullable pointer type 'const void * _Nonnull' [-Werror,-Wnullable-to-nonnull-conversion]
if (!inet_ntop(he->h_addrtype, he->h_addr_list[i], host, sizeof(host))) {
```
For
```
const char* _Nullable inet_ntop(int __af, const void* _Nonnull __src, char* _Nonnull __dst, socklen_t __size);
```
`he->h_addr_list[i]` is not allowed to be null but `h_addr_list` is allowed to be null in the struct:
```
struct hostent {
char * _Nullable h_name; /* official name of host */
char * _Nullable * _Nullable h_aliases; /* alias list */
int h_addrtype; /* host address type */
int h_length; /* length of address */
char * _Nullable * _Nullable h_addr_list; /* list of addresses from name server */
#define h_addr h_addr_list[0] /* address, for backward compatibility */
};
```
But the whole code is
```
while (he->h_addr_list[i] != nullptr) {
char host[INET6_ADDRSTRLEN];
if (!inet_ntop(he->h_addrtype, he->h_addr_list[i], host, sizeof(host))) {
```
We think the compiler should know `he->h_addr_list[i]` is checked before.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzEVk-P4rgT_TTmUgIFBxJy4ADNIP30W_Wht6WW5hI5TiXxYFyR7cD0fPqVzZ-GXnpW2suiKHGqXM-vnqtihHOqNYhLNl-z-WYkBt-RXX5XPwbzvRP09PT_UUX1-7LzvncsXTG-ZXwrTG1J1eNqULqetEStxl7jz4mkPePbaHaMb91Q7ZX3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