- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Intel C++ Compiler 11.1.071 [Intel 64]
Following program compiles clean on /W5:
[bash]#include#include int main() { unsigned __int64 value = 1000; unsigned long index [2] = {123, 456}; printf("%u %u\n", (unsigned)index[0], (unsigned)index[1]); _BitScanForward64(&index[0], value); printf("%u %u\n", (unsigned)index[0], (unsigned)index[1]); } [/bash]
The output is:
[bash]123 456 3 0[/bash]
Expected output is:
[bash]123 456 3 456[/bash]
I.e. _BitScanForward64() treats index as __int64, thus overwrites memory after it.
Documentation clearly states that for both 32 and 64 bit versions index is unsigned long:
unsigned char _BitScanForward(
unsigned long * Index,
unsigned long Mask
);
unsigned char_BitScanForward64(
unsigned long * Index,
unsigned __int64 Mask
);
The same applies to _BitScanReverse64().
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Is it appropriate place for posting error reports? Maybe I need to send it somewhere else?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Dmitriy,
Thanks for your problem report. I'm looking into this issue now. Will get back to you soon.
Thank you. -- Feilong H. Intel Developer Support Tools Knowledge Base: http://software.intel.com/en-us/articles/tools |
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I tested with VS2005. Same output. I'm looking into further. Any input is welcome.
C:\>type test.c
#include
#include
#pragma intrinsic(_BitScanForward64)
int main()
{
unsigned __int64 value = 1000;
unsigned long index[2] = {123, 456};
printf("%u %u\n", (unsigned)index[0], (unsigned)index[1]);
_BitScanForward64(&index[0], value);
printf("%u %u\n", (unsigned)index[0], (unsigned)index[1]);
}
C:\>cl test.c
Microsoft C/C++ Optimizing Compiler Version 14.00.50727.762 for x64
Copyright (C) Microsoft Corporation. All rights reserved.
test.c
Microsoft Incremental Linker Version 8.00.50727.762
Copyright (C) Microsoft Corporation. All rights reserved.
/out:test.exe
test.obj
C:\>test
123 456
3 0
C:\>
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
That just suggests that VC2005 has the same bug. Such behavior can't be correct in any circumstances - compiler silently machine-guns random memory (we, C/C++ developers, like to do that by ourselfs, but we can't permit a compiler to do the same).
Anyway, my VC2008 outputs:
123 456
3 456
And when I recompile my real program with ICC it firmly crashes.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Dmitriy,
Thanks for your input. I just entered this issue to our problem-tracking database. I'll let you know when there is an update regarding this issue.
Thanks,
Feilong
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Just an update. Engineering has implemented a fix for this issue. I'll let you know when a compiler update contains this fix is available for download.
Feilong
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks,
Feilong
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page