public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/50347] New: unexpected -Wconversion error from gcc builtin
@ 2011-09-10  8:45 gcc.hall at gmail dot com
  2011-09-10 10:19 ` [Bug c/50347] " gcc.hall at gmail dot com
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: gcc.hall at gmail dot com @ 2011-09-10  8:45 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50347

             Bug #: 50347
           Summary: unexpected -Wconversion error from gcc builtin
    Classification: Unclassified
           Product: gcc
           Version: 4.6.1
            Status: UNCONFIRMED
          Severity: minor
          Priority: P3
         Component: c
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: gcc.hall@gmail.com


This message is produced from the code example below.

bug.c: In function 'main':
bug.c:17:2: warning: conversion to 'long long int' from 'long long unsigned
int' may change the sign of the result [-Wsign-conversion]

builtin_ffsll is documented as:-
Built-in Function: int __builtin_ffsll (unsigned long long)

    Similar to __builtin_ffs, except the argument type is unsigned long long. 

Note this does not happen with the other similar builtin's (__ctzll for
example)

-----------------------------------------------------------------
#include <stdio.h>
#include <stdlib.h>

int
main( int argc, char *argv[] )
{
  if( argc > 1 )
  {
    char *tail;
    unsigned long long n = strtoull( argv[1], &tail, 0 );
    if( tail == argv[1] )
      return 1;

    int lsb = __builtin_ffsll( n );

    printf("lsb = %d\n", lsb );
  }
  return 0;
}
-------------------------------------------------------------------
* gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/local/libexec/gcc/i686-pc-linux-gnu/4.6.1/lto-wrapper
Target: i686-pc-linux-gnu
Configured with: ../gcc-4.6.1/configure
Thread model: posix
gcc version 4.6.1 (GCC)


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2014-03-27 15:59 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-09-10  8:45 [Bug c/50347] New: unexpected -Wconversion error from gcc builtin gcc.hall at gmail dot com
2011-09-10 10:19 ` [Bug c/50347] " gcc.hall at gmail dot com
2011-09-11  0:38 ` gcc.hall at gmail dot com
2012-06-07 14:02 ` manu at gcc dot gnu.org
2014-03-25 20:53 ` mpolacek at gcc dot gnu.org
2014-03-27 15:59 ` mpolacek at gcc dot gnu.org
2014-03-27 15:59 ` mpolacek at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).