+ Reply to Thread
Results 1 to 3 of 3
  1. #1
    Junior Member
    Join Date
    Feb 2009
    Posts
    2

    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.

  2. #2
    Ultimate Member dchw_dude's Avatar
    Join Date
    Nov 2004
    Location
    Provo, UT
    Posts
    1,356
    Oops. Sorry - wrong answer. What OS are you using to produce the warnings above?

    TechIMO Folding@home Team #111 - Crunching for the cure!

  3. #3
    Junior Member
    Join Date
    Feb 2009
    Posts
    2
    I could easily get warnings on Solaris OS using CC +w2 -xarch=v9 but, even after trying almost all the compiler switces, I am not getting truncation warnings on SUSE 64 bit.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Assigning specific applications to specific sound devices
    By Technoobalicious in forum Technical Support
    Replies: 0
    Last Post: December 13th, 2008, 09:01 AM

Tags for this Thread

Posting Permissions

  • You may post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Recommended Sites: ResellerRatings Store Reviews