Pages

Wrong optimization in class analysis when calling virtual function

Kamis, 26 Mei 2011

Reference Number : 
DPD200167436

Version : 
Intel C++ compiler 12.0

Operating System : 
Windows

Problem Description : 

Intel C++ compiler is doing wrong "class analysis" optimization when calling virtual function, implemented both in a plug-in and in the calling module.

When we compile the following test case with Intel compiler 12.0, we get wrong output. If we remove /Qipo option, the issue is does not show up.

// plugin.h    #pragma once    struct Interface  {      virtual void __stdcall Member() = 0;  };  

// plugin.cpp    #include "Plugin.h"  #include <stdio.h>    struct Implementation : public Interface  {      virtual void __stdcall Member()      {          printf("Plugin implementation\n");      }  };    extern "C" __declspec(dllexport)  Interface * _cdecl PluginCreator()  {      return new Implementation();  }  

// caller.cpp    #include "Plugin.h"  #include <stdio.h>    extern "C" Interface * _cdecl PluginCreator();    struct CallerImplementation : public Interface  {      virtual void __stdcall Member()      {          printf("Caller implementation\n");      }  };    int main(int argc, char ** argv)  {      Interface * caller = new CallerImplementation();      Interface * plugin = PluginCreator();        //__debugbreak();      caller->Member();      plugin->Member();     printf("Done\n");      return 0;  }  



C:\>icl -c /Qvc10 /Zi /W3 /O2 /Oi /Qipo /Qftz- -D WIN32 -D NDEBUG -D _WINDOWS -D _USRDLL -D _WINDLL -D _UNICODE -DUNICODE /EHsc /MD /GS /Gy /fp:precise /Zc:wchar_t /Zc:forScope /Gd /TP Plugin.cpp


C:\> icl /Qoption,link,/OUT:Plugin.dll /Qoption,link,/DLL "kernel32.lib" "user32.lib" Plugin.obj

C:> icl -c /Qvc10 /Zi /W3 /O2 /Oi /Qipo /Qftz- -D WIN32 -D NDEBUG -D _CONSOLE -D _UNICODE -D UNICODE /EHsc /MD /GS /Gy /fp:precise /Zc:wchar_t /Zc:forScope /Gd /TP -Qopt-class-analysis- Caller.cpp

C:>\ icl caller.obj Plugin.lib

The sample code for demonstrating the issue is taken from the Intel C++ compiler user forum, link http://software.intel.com/en-us/forums/showthread.php?t=81587&p=1#151043


Resolution Status : 

A bug in "class analysis" optimization is the cause for this runtime issue. We do have external option (-Qopt-class-analysis-) to disable this optimization. For now, this option can be used as workaround to avoid this issue.

Ex:
icl -Qopt-class-analysis- caller.obj Plugin.lib



[DISCLAIMER: The information on this web site is intended for hardware system manufacturers and software developers. Intel does not warrant the accuracy, completeness or utility of any information on this site. Intel may make changes to the information or the site at any time without notice. Intel makes no commitment to update the information at this site. ALL INFORMATION PROVIDED ON THIS WEBSITE IS PROVIDED "as is" without any express, implied, or statutory warranty of any kind including but not limited to warranties of merchantability, non-infringement of intellectual property, or fitness for any particular purpose. Independent companies manufacture the third-party products that are mentioned on this site. Intel is not responsible for the quality or performance of third-party products and makes no representation or warranty regarding such products. The third-party supplier remains solely responsible for the design, manufacture, sale and functionality of its products. Intel and the Intel logo are trademarks or registered trademarks of Intel Corporation or its subsidiaries in the United States and other countries. *Other names and brands may be claimed as the property of others.]

25 May, 2011


--
Source: http://software.intel.com/en-us/articles/wrong-optimization-in-class-analysis-when-calling-virtual-function/
~

0 komentar:

Posting Komentar

Ayo gan Komentarnya jangan lupa,,,biar tambah semangat yang upload Film dan Game dan berita juga update artikelnya, kalau ada link yang mati laporkan juga disini ya...

 
gamers holic dan security web dan aneka ragam © 2011 | Designed by Bingo Cash, in collaboration with Modern Warfare 3, VPS Hosting and Compare Web Hosting
Related Posts Plugin for WordPress, Blogger...