<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/xhtml; charset=utf-8">
</head>
<body>
<div style="font-family:sans-serif"><div style="white-space:normal"><p dir="auto">Trying to use _Generic to ensure the expression has the expected type.</p>
<p dir="auto">How would you do the static assertion, it would lead to<br>
the exactly same issue as I am hitting here, no?</p>
<p dir="auto">On 7 Aug 2020, at 19:52, Rémi Denis-Courmont wrote:</p>
</div>
<blockquote style="border-left:2px solid #777; color:#777; margin:0 0 5px; padding-left:5px"><div id="D9C5BB4A-4402-4673-9FD3-85ECB33CC4CB">I don't know what you're trying to do there, and that does not look like a static assertion to me.<br><br><div class="gmail_quote">Le 7 août 2020 16:37:47 GMT+03:00, Marvin Scholz <epirat07@gmail.com> a écrit :<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<pre class="k9mail"><br><br>On 7 Aug 2020, at 14:42, Rémi Denis-Courmont wrote:<br><br><blockquote class="gmail_quote" style="margin: 0pt 0pt 1ex 0.8ex; border-left: 1px solid #729fcf; padding-left: 1ex;"> Hi,<br><br> You can use _Generic() if you want to match types. No need for <br> compiler-dependent ifdef'ery.<br><br> Might be overkill here though.<br></blockquote><br>I thought about that too but the following does not work:<br><br># define VLC_ALIGNOF(t, expr) \<br>   (_Generic(expr, t: _Alignof(t)))<br><br>atomic_uint *addr;<br>VLC_ALIGNOFT(atomic_uint, *addr);<br><br>This fails to compile with:<br>error: '_Generic' selector of type 'unsigned int' is not compatible with <br>any association<br><br>><br><blockquote class="gmail_quote" style="margin: 0pt 0pt 1ex 0.8ex; border-left: 1px solid #729fcf; padding-left: 1ex;">Le 7 août 2020 07:55:35 GMT+03:00, Steve Lhomme <robux4@ycbcr.xyz> a <br>écrit :<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 1ex 0.8ex; border-left: 1px solid #ad7fa8; padding-left: 1ex;"> OK for both. Although it would be nice to have a safety check in case<br> the underlying type changes and the alignof is not valid anymore.<br><br> May a static_assert when compiling with GCC, like<br> #if defined(__GNUC__) && !defined(__llvm__) &&<br> !defined(__INTEL_COMPILER)<br> static_assert(alignof(*addr) == alignof(atomic_uint), "type <br> mismatch");<br> #endif<br><br><br> On 2020-08-07 6:44, Marvin Scholz wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 1ex 0.8ex; border-left: 1px solid #8ae234; padding-left: 1ex;"> Using alignof not on a type but an expression is a GNU extension and<br> causes the following warning:<br><br>     warning: '_Alignof' applied to an expression is a GNU extension<hr>   src/posix/wait.c | 2 +-<br>   1 file changed, 1 insertion(+), 1 deletion(-)<br><br> diff --git a/src/posix/wait.c b/src/posix/wait.c<br> index 584cc493b1a..3fa6890193a 100644<br> --- a/src/posix/wait.c<br> +++ b/src/posix/wait.c<br> @@ -52,7 +52,7 @@ static struct wait_bucket<br>   static struct wait_bucket *wait_bucket_get(atomic_uint *addr)<br>   {<br>       uintptr_t u = (uintptr_t)addr;<br> -    size_t idx = (u / alignof (*addr)) % ARRAY_SIZE(wait_buckets);<br> +    size_t idx = (u / alignof (atomic_uint)) %<br></blockquote>ARRAY_SIZE(wait_buckets);<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 1ex 0.8ex; border-left: 1px solid #8ae234; padding-left: 1ex;">       return &wait_buckets[idx];<br>   }<br> -- <br> 2.24.3 (Apple Git-128)<hr> vlc-devel mailing list<br> To unsubscribe or modify your subscription options:<br> <a href="https://mailman.videolan.org/listinfo/vlc-devel">https://mailman.videolan.org/listinfo/vlc-devel</a><br><br></blockquote><hr>vlc-devel mailing list<br>To unsubscribe or modify your subscription options:<br><a href="https://mailman.videolan.org/listinfo/vlc-devel">https://mailman.videolan.org/listinfo/vlc-devel</a><br></blockquote>-- <br>Envoyé de mon appareil Android avec Courriel K-9 Mail. Veuillez <br>excuser ma brièveté.<br></blockquote><br><br><blockquote class="gmail_quote" style="margin: 0pt 0pt 1ex 0.8ex; border-left: 1px solid #729fcf; padding-left: 1ex;"><hr>vlc-devel mailing list<br>To unsubscribe or modify your subscription options:<br><a href="https://mailman.videolan.org/listinfo/vlc-devel">https://mailman.videolan.org/listinfo/vlc-devel</a><br></blockquote><hr>vlc-devel mailing list<br>To unsubscribe or modify your subscription options:<br><a href="https://mailman.videolan.org/listinfo/vlc-devel">https://mailman.videolan.org/listinfo/vlc-devel</a></pre></blockquote></div><br>-- <br>Envoyé de mon appareil Android avec Courriel K-9 Mail. Veuillez excuser ma brièveté.</div></blockquote>
<div style="white-space:normal"><blockquote style="border-left:2px solid #777; color:#777; margin:0 0 5px; padding-left:5px">
</blockquote><blockquote style="border-left:2px solid #777; color:#777; margin:0 0 5px; padding-left:5px"><p dir="auto">_______________________________________________<br>
vlc-devel mailing list<br>
To unsubscribe or modify your subscription options:<br>
<a href="https://mailman.videolan.org/listinfo/vlc-devel" style="color:#777">https://mailman.videolan.org/listinfo/vlc-devel</a></p>
</blockquote></div>
</div>
</body>
</html>