<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<html lang="en">
<head>
<meta content="text/html; charset=US-ASCII" http-equiv="Content-Type">
<title>
GitLab
</title>
<style>img {
max-width: 100%; height: auto;
}
</style>
</head>
<body>
<div class="content">
<p class="details" style="font-style: italic; color: #666;">
<a href="https://gitlab.com/gvanem">Gisle Vanem</a> created an issue: <a href="https://gitlab.com/gnutls/gnutls/-/issues/1336">#1336</a>
</p>
<div></div>
<p dir="auto">Compiling the <code>debug.c</code> file with <code>cl -c -DDEBUG ...</code> (with MSVC-2019), yields this error:</p>
<div class="gl-relative markdown-code-block js-markdown-code">
<pre class="code highlight js-syntax-highlight language-c" lang="c" v-pre="true" style="border-radius: 2px; margin: 0 0 8px; padding: 8px 12px; border: 1px solid #dbdbdb;"><code><span id="LC1" class="line" lang="c"><span class="n">debug</span><span class="p">.</span><span class="n">c</span><span class="p">(</span><span class="mi">47</span><span class="p">)</span><span class="o">:</span> <span class="n">error</span> <span class="n">C2057</span><span class="o">:</span> <span class="n">expected</span> <span class="n">constant</span> <span class="n">expression</span></span>
<span id="LC2" class="line" lang="c"><span class="n">debug</span><span class="p">.</span><span class="n">c</span><span class="p">(</span><span class="mi">47</span><span class="p">)</span><span class="o">:</span> <span class="n">error</span> <span class="n">C2466</span><span class="o">:</span> <span class="n">cannot</span> <span class="n">allocate</span> <span class="n">an</span> <span class="n">array</span> <span class="n">of</span> <span class="n">constant</span> <span class="n">size</span> <span class="mi">0</span></span>
<span id="LC3" class="line" lang="c"><span class="n">debug</span><span class="p">.</span><span class="n">c</span><span class="p">(</span><span class="mi">47</span><span class="p">)</span><span class="o">:</span> <span class="n">error</span> <span class="n">C2133</span><span class="o">:</span> <span class="err">'</span><span class="n">buf_hex</span><span class="err">'</span><span class="o">:</span> <span class="n">unknown</span> <span class="n">size</span></span>
<span id="LC4" class="line" lang="c"><span class="n">debug</span><span class="p">.</span><span class="n">c</span><span class="p">(</span><span class="mi">51</span><span class="p">)</span><span class="o">:</span> <span class="n">warning</span> <span class="n">C4034</span><span class="o">:</span> <span class="k">sizeof</span> <span class="n">returns</span> <span class="mi">0</span></span></code></pre>
<copy-code></copy-code>
</div>
<p dir="auto">Wouldn't it be better by using <code>alloca()</code> for MSVC in this case:</p>
<div class="gl-relative markdown-code-block js-markdown-code">
<pre class="code highlight js-syntax-highlight language-diff" lang="diff" v-pre="true" style="border-radius: 2px; margin: 0 0 8px; padding: 8px 12px; border: 1px solid #dbdbdb;"><code><span id="LC1" class="line" lang="diff"><span class="gd">--- a/lib/debug.c 2022-03-13 16:34:15</span></span>
<span id="LC2" class="line" lang="diff"><span class="gi">+++ b/lib/debug.c 2022-03-14 11:28:50</span></span>
<span id="LC3" class="line" lang="diff"><span class="p">@@ -44,7 +44,11 @@</span></span>
<span id="LC4" class="line" lang="diff"> void</span>
<span id="LC5" class="line" lang="diff"> _gnutls_dump_vector(const char *prefix, const uint8_t * a, size_t a_size)</span>
<span id="LC6" class="line" lang="diff"> {</span>
<span id="LC7" class="line" lang="diff"><span class="gd">- char buf_hex[2 * a_size + 1];</span></span>
<span id="LC8" class="line" lang="diff"><span class="gi">+#ifdef _MSC_VER</span></span>
<span id="LC9" class="line" lang="diff"><span class="gi">+ char *buf_hex = alloca (2 * a_size + 1);</span></span>
<span id="LC10" class="line" lang="diff"><span class="gi">+#else</span></span>
<span id="LC11" class="line" lang="diff"><span class="gi">+ char *buf_hex[2 * a_size + 1];</span></span>
<span id="LC12" class="line" lang="diff"><span class="gi">+#endif</span></span></code></pre>
<copy-code></copy-code>
</div>
<p dir="auto">But I cannot see this functions is called anywhere. So why is it there?</p>
<p dir="auto">I made a similar <a href="https://gitlab.com/gnutls/gnutls/-/issues/248" data-original="issue" data-link="true" data-link-reference="true" data-project="179611" data-issue="6470379" data-reference-type="issue" data-container="body" data-placement="top" title="Compiling with DEBUG" class="gfm gfm-issue has-tooltip">issue</a> 4 years ago.
And I'm amazed MSVC is still not fully supported.</p>
</div>
<div class="footer" style="margin-top: 10px;">
<p style="font-size: small; color: #666;">
—
<br>
Reply to this email directly or <a href="https://gitlab.com/gnutls/gnutls/-/issues/1336">view it on GitLab</a>.
<br>
You're receiving this email because of your account on gitlab.com.
If you'd like to receive fewer emails, you can
<a href="https://gitlab.com/-/sent_notifications/ca2a791d9da8bb6d9594016046ebad61/unsubscribe">unsubscribe</a>
from this thread or
adjust your notification settings.
<script type="application/ld+json">{"@context":"http://schema.org","@type":"EmailMessage","action":{"@type":"ViewAction","name":"View Issue","url":"https://gitlab.com/gnutls/gnutls/-/issues/1336"}}</script>
</p>
</div>
</body>
</html>