- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I have a question about warning 167, which ICC prints for the following testcase: [cpp] #include <xmmintrin.h>
void foo(__m128i) {}
int main() {
foo(_mm_setzero_ps());
return 0;
}
[/cpp] Why is this not an error? I mean how can a C++ compiler do an automatic cast from four floats to 2/4/8/16 signed/unsigned integers? And no, of course it doesn't do a conversion it just does a reinterpret_cast. Good that there's a warning, but I don't understand the rationale for not making this an error.
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I have submiited a report, # DPD200240331, on this to Intel compiler dvelopment team. I will update when I have more information on this.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Sergey Kostrov wrote:
So, sizes are identical.
Then, Intel C++ compiler could pick unsigned __int64 m128_u64[2] from __m128 and unsigned __int64 m128i_u64[2] from __m128i to complete a cast with the warning message.
[cpp]
printf("%lld - %lld\n", sizeof(float), sizeof(char[4]));
[/cpp]
I don't think equal sizes is a good argument for or against whether a cast is/should be possible. Automatic casts between differently sized integers are perfectly fine. Obviously, one can't really argue with the C++ spec here, because the SSE intrinsics are a compiler extensions developed by Intel. But it certainly makes sense to have this extension follow the spirit of the C++ spec wherever possible. If you avoid surprises in the language you can avoid serious bugs... In C++ automatic conversions between floating point and integer types exists. But nothing like this here, where float values are reinterpreted as some integers of unknown size. For builtin types this would always result in a compile error and the requirement to have the developer actually write down what he wants.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Maybe, it's interesting for you to know the background: I actually did not create such broken code myself (I develop my code mostly with GCC, which does not compile this example). But while trying to reduce a miscompilation of ICC, a delta run reduced the code to a rather broken state - because ICC did not error out...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page