Wrong optimization when calling virtual function implemented both in a plugin and in the calling module.

Wrong optimization when calling virtual function implemented both in a plugin and in the calling module.

HiIntel 12 Compiler seems to inline virtual functions where he should'nt (when optimization and IPO enabled).
The given solution should output (tested with Intel Compiler 11 and Visual C++ 2005/2008)Caller implementationPlugin implementationBut if i compile the Caller (EXE) with Intel 12 (Compiler XE [IA-32]), with /O2 and /Qipoit outputsCaller implementationCallerimplementationThis is very surprising from a professionnal compiler to have such a subjective interpretation of the keyword "virtual"...Regards,Emmanuel

Downloadapplication/zip WithoutDynamicLoading.zip4.96 KB
11 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

This seems a bug in Intel compiler. I am investigating the issue. I will update when done.

I reproduced the issue using VS2010 IDE.

I could not reproduce the issue when using command lines give below:

c:\>icl /c /Qvc10 /Zi /W3 /O2 /Oi /Qipo /Qftz- -D WIN32 -D NDEBUG -D _WINDOWS -D _USRDLL -D INTEL12BUGPLUGIN_EXPORTS -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:Intel12BugPlugin.dll /Qoption,link,/DLL "kernel32.lib" "user32.lib" "gdi32.lib" "winspool.lib" "comdlg32.lib" "advapi32.lib" "shell32.lib" "ole32.lib" "oleaut32.lib" "uuid.lib" "odbc32.lib" "odbccp32.lib" Plugin.obj

c:\>icl /c /Qvc10 /Zi /W3 /Od /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 Caller.cpp

c:>icl Intel12BugPlugin.lib Caller.obj

Is there something missing?

I don't understand, did you manage to reproduce the bug within the IDE or do you need me to send you a solution with Visual 2010 ?I'm not use to command line, although running the lines you gave me the compiler outputs:ipo: remark #11001: performing single-file optimizationsAnd I don't know how to force multi-file optimization (because I already tested like I said in the initial post that the bug happen only in multi-file optimization (/Qipo) and not single fine optimization (/Qip).Obviously in single-file optimization, the compiler has no hint to issue make static call from virtual call.

After some trial, I have reproduced the bug with the following command lines:

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/Plugin.cpp
icl /Qoption,link,/OUT:Plugin.dll /Qoption,link,/DLL "kernel32.lib" "user32.lib" Plugin.obj
icl /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 Caller/Caller.cpp Plugin.lib

I have submitted a bug report to Intel compiler development team on this. I will update the thread when I have more info on this.

If you use compiler option -Qopt-class-analysis- then the problem is resolved.

Hi, thanks for your fix, it will be very usefull.It this still considered as a bug to be solved by the Compiler Team ?Best regards and thanks again.

The fix is implemeted by compiler team but it is not targeted for Intel compiler 12.0.

In case you can not manage with work-around, please let us know.

The issue is fixed in latest Intel C++ Composer XE 12.1. The composer is available for download from Intel download center.

Leave a Comment

Please sign in to add a comment. Not a member? Join today