LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 02-21-2009, 02:11 AM   #1
skaushal.schip
LQ Newbie
 
Registered: Feb 2009
Posts: 1

Rep: Reputation: 0
Question Not getting 64 bit specific truncation warnings.


Dear All,

I am porting my C/C++ project (currently functioning on 32 bit machine) into 64 bit SUSUE linux machine
uname -a
Linux msglxd03 2.6.5-7.97-smp #1 SMP Fri Jul 2 14:21:59 UTC 2004 x86_64 x86_64 x86_64 GNU/Linux

I am trying to get the warning Specific to long to int and pointer to int assignments.

===================================
Written warnings2.c file which conatin :

#include<stdio.h>
#include<stdlib.h>
int main()
{
unsigned int i;
unsigned long z = -1L;

printf("size of unsigned is %d bytes!\n", sizeof(z));
printf("size of int is %d bytes!\n", sizeof(i));

i = z;
printf("\ni is = %d",i);
i = &z;
printf("\ni is = %d",i);
return 1;
}
==========================
After compiling (either with gcc or cc)

$ gcc -m64 -Wall -march=x86-64 -o war2.o warnings2.c

it gave me following warning:

warnings2.c: In function main:
warnings2.c:9: warning: format %d expects type int, but argument 2 has type long unsigned int
warnings2.c:10: warning: format %d expects type int, but argument 2 has type long unsigned int
warnings2.c:14: warning: assignment makes integer from pointer without a cast

There isn't any warning for long to int assignment(truncation) @ line 12.

On sparcv9 it is giving warnings when used >> CC +w2 -xarch=v9
"warnings2.cpp", line 12: Warning: Conversion of 64 bit type value to "int" causes truncation.
1 Warning(s) detected.

Could anybody please tell me how could we get the similar warnings on Linux?
Which all options are need with gcc to get the truncation warnings on 64-bit linux machine?
We have already tried -m64 -Wall -mcpu=x86-64 -Wconversion -pedantic and -Wshorten-64-to-32, but didn't get truncation warnings ?

Thanks in advance,

Regards.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Multisession cd rw File name truncation Aravind Kumar Linux - Software 2 07-12-2008 05:26 AM
MP3 Truncation mmiikkee12 Linux - Software 2 09-02-2007 01:19 AM
Duplicate warnings of apt-get in a 64-bit system jlblom Linux - Software 2 12-07-2005 03:11 AM
C++ Rounding and Truncation Opeth Programming 4 09-17-2005 07:16 PM
Truncation problem Big Al Debian 3 04-12-2004 08:26 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 09:32 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration