PGI User Forum
 SearchSearch   MemberlistMemberlist     RegisterRegister   ProfileProfile    Log inLog in 

CUDA-x86.

Compiler bug in pgcpp

 
Post new topic   Reply to topic    PGI User Forum Forum Index -> Programming and Compiling
View previous topic :: View next topic  
Author Message
delph



Joined: 10 Nov 2010
Posts: 1

PostPosted: Thu Feb 14, 2013 2:47 am    Post subject: Compiler bug in pgcpp Reply with quote

Hi,

I found a compiler bug in pgcpp 13.2-0 64-bit target on x86-64 Windows. The bug is caused due to erroneous optimization. Here is a test program that reproduces the bug:

Code:

/// Usage:
/// $ pgcpp bug.cpp -o bug
/// $ ./bug 10
/// $ pgcpp -fast bug.cpp -o bug
/// $ ./bug 10

#include <iostream>
#include <limits>
#include <cstdlib>
#include <stdint.h>

int main(int, char* argv[])
{
  if (argv[1]) {
    uint64_t MAX_UINT32 = std::numeric_limits<uint32_t>::max();
    uint64_t MAX_UINT64 = std::numeric_limits<uint64_t>::max();

    int factor = atoi(argv[1]);
    uint64_t result = MAX_UINT64 - MAX_UINT32 * factor;

    std::cout << result << std::endl;
  }
}


The non optimized version prints the correct result '18446744030759878665' while the optimized version (-fast or -O2) prints '9' which is an error.
Back to top
View user's profile
mkcolg



Joined: 30 Jun 2004
Posts: 6129
Location: The Portland Group Inc.

PostPosted: Thu Feb 14, 2013 10:21 am    Post subject: Reply with quote

Thanks Delph, I have sent a report to our engineers (TPR#19133) who will investigate this further.

The two quick work arounds that I see are to add the "volatile" attribute to MAX_UINT32 or disable auto-inlining (-Mnoautoinline).

- Mat
Back to top
View user's profile
jtull



Joined: 30 Jun 2004
Posts: 438

PostPosted: Fri Jun 07, 2013 4:28 pm    Post subject: TPR 19133 is fixed in the 13.6 release. Reply with quote

TPR 19133 - Wrong answers when using optimization and integer limits.

Fixed in 13.6. Available now.

regards,
dave
Back to top
View user's profile
Display posts from previous:   
Post new topic   Reply to topic    PGI User Forum Forum Index -> Programming and Compiling All times are GMT - 7 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © phpBB Group