Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I ran into this breaking change when I used GCC. The compiler printed an error for code like this:</p> <pre><code>void foo(const unsigned long long &amp;i) { unsigned int a[2] = {i &amp; 0xFFFFFFFF, i &gt;&gt; 32}; } </code></pre> <blockquote> <p>In function <code>void foo(const long long unsigned int&amp;)</code>:</p> <p>error: narrowing conversion of <code>(((long long unsigned int)i) &amp; 4294967295ull)</code> from <code>long long unsigned int</code> to <code>unsigned int</code> inside { }</p> <p>error: narrowing conversion of <code>(((long long unsigned int)i) &gt;&gt; 32)</code> from <code>long long unsigned int</code> to <code>unsigned int</code> inside { }</p> </blockquote> <p>Fortunately, the error messages were straightforward and the fix was simple:</p> <pre><code>void foo(const unsigned long long &amp;i) { unsigned int a[2] = {static_cast&lt;unsigned int&gt;(i &amp; 0xFFFFFFFF), static_cast&lt;unsigned int&gt;(i &gt;&gt; 32)}; } </code></pre> <p>The code was in an external library, with only two occurrences in one file. I don't think the breaking change will affect much code. Novices might <a href="https://stackoverflow.com/questions/4490111/have-narrowing-conversion-error-in-c-arm-from-android-ndk" title="Have narrowing conversion error in C++ arm from Android NDK - Stack Overflow">get</a> <a href="https://stackoverflow.com/questions/3719848/char-and-initializer-lists" title="conversion - char and initializer lists - Stack Overflow">confused,</a> though.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload