From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 32462 invoked by alias); 7 Mar 2011 14:20:03 -0000 Received: (qmail 32376 invoked by uid 22791); 7 Mar 2011 14:20:00 -0000 X-SWARE-Spam-Status: No, hits=-2.4 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,T_TO_NO_BRKTS_FREEMAIL X-Spam-Check-By: sourceware.org Received: from mail-ew0-f47.google.com (HELO mail-ew0-f47.google.com) (209.85.215.47) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 07 Mar 2011 14:19:35 +0000 Received: by ewy8 with SMTP id 8so1276281ewy.20 for ; Mon, 07 Mar 2011 06:19:33 -0800 (PST) MIME-Version: 1.0 Received: by 10.216.253.227 with SMTP id f77mr3344613wes.86.1299507572954; Mon, 07 Mar 2011 06:19:32 -0800 (PST) Received: by 10.216.87.137 with HTTP; Mon, 7 Mar 2011 06:19:32 -0800 (PST) In-Reply-To: References: Date: Mon, 07 Mar 2011 14:20:00 -0000 Message-ID: Subject: Re: Warning using -Wconversion and -Ox in gcc 4.5 and 4.6 but not in previous releases From: =?ISO-8859-1?Q?Jos=E9_Luis_Garc=EDa_Pallero?= To: gcc-help@gcc.gnu.org Cc: Marc Glisse Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: quoted-printable Mailing-List: contact gcc-help-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-help-owner@gcc.gnu.org X-SW-Source: 2011-03/txt/msg00067.txt.bz2 El d=EDa 7 de marzo de 2011 14:16, Marc Glisse escri= bi=F3: > On Mon, 7 Mar 2011, Jos=E9 Luis Garc=EDa Pallero wrote: > >> Hello, >> In this example: >> >> #include >> #include >> int main() { >> =A0 strspn("hello","h"); >> =A0 return 0; >> } >> >> I obtain a warning as: >> >> test.c:4:5: warning: conversion to =91size_t=92 from =91int=92 may chang= e the >> sign of the result >> >> If I compile the program with the options: >> >> gcc -Wconversion -O test.c -o test > > Note that your example can be reduced to: > int main() { > =A0 =A0 =A0 =A0(0 ? ((void) (0), 0) : 1u) ; > =A0 =A0 =A0 =A0return 0; > } > > Not a most useful warning indeed... > >> The warning appears with -O, -O1, -O2 and -O3, but not with -O0. > > glibc includes different code when __OPTIMIZE__ is defined. > > -- > Marc Glisse > But why in previous gcc versions the warning didn't appears. And strspn() is a common function in string.h. I don't understand why the call to strspn() with correct arguments emits a warning. --=20 ***************************************** Jos=E9 Luis Garc=EDa Pallero jgpallero@gmail.com (o< / / \ V_/_ Use Debian GNU/Linux and enjoy! *****************************************