PGI User Forum
 SearchSearch   MemberlistMemberlist     RegisterRegister   ProfileProfile    Log inLog in 

CUDA-x86.

Problem with casting

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



Joined: 28 Oct 2004
Posts: 1

PostPosted: Mon Mar 13, 2006 1:09 pm    Post subject: Problem with casting Reply with quote

The latest netcdf-4.0-alpha was released recently and when I compile it with pgcc, I get test failures that don't show up when compiled with intel or GNU compilers. I have tried this with both pgcc-5.1-6 and pgcc-6.0-5 on i686. I isolated the problem to a small snippet shown below:

Code:

#include <stdio.h>
int main() {
  short shrt, shrt2;
  int value;

  value = 100000;
  shrt = -31072;
 
  shrt2 = value;
  if (!(shrt == shrt2)) printf("Error 1\n");
  if (shrt != shrt2) printf("Error 2\n");
  if (!(shrt == (short)value)) printf("Error 3\n");
  if (shrt != (short)value) printf("Error 4\n");
}


When run, I get the output

Quote:
sahp6588> pgcc test.c -o test.pgi
sahp6588> ./test.pgi
Error 1
Error 3
Error 4



When compiiled and run with intel-8.1, intel-9.0, and gcc-3.4.5, gcc-4.1.0, I get no output.

Anyone see what I am doing wrong?
Back to top
View user's profile
mkcolg



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

PostPosted: Mon Mar 13, 2006 3:15 pm    Post subject: Reply with quote

Hi GSj,

Add "-Msignextend" to your compilation.

Code:
% pgcc tmp.c
% a.out
Error 1
Error 3
Error 4
% pgcc tmp.c -Msignextend
% a.out
%


- Mat
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