Loading...
You are not logged-in Login/Register





  • Posts   Search Threads
  • stephan_November 13, 2008 9:59 AM PST   
    Compiler bug in handling of long long template arguments

    Hi,

    The test case below demonstrates a rather unfortunate bug in the Intel C++ 10.1 and 11 (I tested the latest evaluation versions). It should print 2^32 and 2^33 but instead prints 2^32 twice. The bug seems only to be triggered if the second number is large enough in magnitude. Both the 32-bit and 64-bit compiler seem to be affected.

    I'd be very interested in any workaround.

    include <iostream>

    template <long long v>
    class Test {
    public:
    long long val() { return v; }
    };

    int main() {
    Test<(1ll << 32)> test1;
    std::cout << test1.val() << std::endl;
    Test<(1ll << 33)> test2;
    std::cout << test2.val() << std::endl;
    return 0;
    }

     



    Igor LevickiNovember 13, 2008 4:44 PM PST
    Rate
     
    Re: Compiler bug in handling of long long template arguments

    I presume that using __int64 or unsigned __int64 is not an option?


    --
    Regards,
    Igor Levicki

    If you find my post helpfull, please rate it and/or select it as a best answer where applies. Thank you.

    Igor LevickiNovember 13, 2008 4:53 PM PST
    Rate
     
    Re: Compiler bug in handling of long long template arguments

    Quoting - Igor Levicki
    I presume that using __int64 or unsigned __int64 is not an option?

    Scratch that, it is a bug:

            push      1                                             ;12.24
            push      0                                             ;12.24
            call      ??6?$basic_ostream@DU?$char_traits@D@std@@@std@@QAEAAV01@_J@Z 
    

    That gets emitted for both 1 << 32 and for 1 << 33. It is the compiler constant calculation which is broken. Workaround is to define proper constants by hand.



    --
    Regards,
    Igor Levicki

    If you find my post helpfull, please rate it and/or select it as a best answer where applies. Thank you.

    Igor LevickiNovember 13, 2008 5:04 PM PST
    Rate
     
    Re: Compiler bug in handling of long long template arguments

    Nope, I am wrong again. It has to do with the template arguments:

    #include <iostream>
     
    template <long long v>
    
    class Test
    {
    public: 
    	long long val() { return v; }
    }; 
    
    int main(void)
    { 
    	const long long c1 = 1ll << 32;
    	const long long c2 = 1ll << 33;
    
    	Test test1; 
    	Test test2; 
    	std::cout << test1.val() << std::endl;
    	std::cout << test2.val() << std::endl;
    	std::cout << c1 << std::endl;
    	std::cout << c2 << std::endl;
    
    	return 0; 
    } 
    

    Using the above test case you can see that the constants work but the template doesn't. I will submit an issue to the Premier Support.



    --
    Regards,
    Igor Levicki

    If you find my post helpfull, please rate it and/or select it as a best answer where applies. Thank you.

    Jennifer Jiang (Intel)November 17, 2008 5:17 PM PST
    Rate
     
    Re: Compiler bug in handling of long long template arguments

    Thanks for the testcase. It's a bug in the compiler. When there's any news, I'll post to this thread.
    Jennifer

     



    Download Intel(R) Compiler Product Updates: Registration Center.
    Try Intel(R) Compiler Products: Intel Software Evaluation Center

    stephan_January 19, 2009 1:28 PM PST
    Rate
     
    Re: Compiler bug in handling of long long template arguments

    Still no news yet?

    (This is a code generation bug that can lead to difficult to detect errors ...)


    Jennifer Jiang (Intel)March 30, 2009 12:43 PM PDT
    Rate
     
    Re: Compiler bug in handling of long long template arguments

    Quoting - stephan_
    Still no news yet?

    (This is a code generation bug that can lead to difficult to detect errors ...)

    The latest 11.0.074 contains the fix.

    You can download the 74 from our eval page or the Intel Registraction/Downlaod Center "https://registrationcenter.intel.com/RegCenter/Register.aspx".

    Jennifer

    Download Intel(R) Compiler Product Updates: Registration Center.
    Try Intel(R) Compiler Products: Intel Software Evaluation Center

Forum jump:  

Intel Software Network Forums Statistics

16,371 users have contributed to 46,346 threads and 163,988 posts to date.

In the past 24 hours, we have 15 new thread(s) 83 new posts(s), and 61 new user(s).

In the past 3 days, the most popular thread for everyone has been Formula for the intersection of straight lines The most posts were made to Take a look at John Burkhard&# The post with the most views is \"-check none\" generates error

Please welcome our newest member claudepi


For more complete information about compiler optimizations, see our Optimization Notice.