public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/53277] New: Warning using -Wconversion and -Ox in gcc 4.5, 4.6 and 4.7 but not in previous releases
@ 2012-05-08  9:00 jgpallero at gmail dot com
  2012-05-08 16:06 ` [Bug c/53277] " pinskia at gcc dot gnu.org
                   ` (19 more replies)
  0 siblings, 20 replies; 21+ messages in thread
From: jgpallero at gmail dot com @ 2012-05-08  9:00 UTC (permalink / raw)
  To: gcc-bugs

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

             Bug #: 53277
           Summary: Warning using -Wconversion and -Ox in gcc 4.5, 4.6 and
                    4.7 but not in previous releases
    Classification: Unclassified
           Product: gcc
           Version: 4.7.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: jgpallero@gmail.com


Hello:

In this example:

#include<stdlib.h>
#include<string.h>
int main() {
    strspn("hello","h");
    return 0;
}

I obtain the warning:

test.c:4:5: warning: conversion to ‘size_t’ from ‘int’ may change the sign of
the result [-Wsign-conversion]

using the order:

gcc -Wall -Wextra -Wconversion -O test.c -o test

The warning appears with -O, -O1, -O2 and -O3, but not with -O0. The
warning appears in gcc 4.5, 4.6 and 4.7 but not in previous releases.

This behavior appears too if I do some assign:

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


int main() {
  size_t x;
  x = strspn("hello","h");
  printf("%zd\n", x);
  return 0;
}

I think this is a bug

Cheers


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

end of thread, other threads:[~2023-06-15  0:34 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-05-08  9:00 [Bug c/53277] New: Warning using -Wconversion and -Ox in gcc 4.5, 4.6 and 4.7 but not in previous releases jgpallero at gmail dot com
2012-05-08 16:06 ` [Bug c/53277] " pinskia at gcc dot gnu.org
2012-05-09 10:51 ` jgpallero at gmail dot com
2012-05-09 10:52 ` jgpallero at gmail dot com
2012-05-09 10:52 ` jgpallero at gmail dot com
2012-05-09 10:53 ` jgpallero at gmail dot com
2012-05-09 10:54 ` jgpallero at gmail dot com
2012-05-09 10:56 ` jgpallero at gmail dot com
2012-05-09 11:06 ` jgpallero at gmail dot com
2012-05-09 12:07 ` glisse at gcc dot gnu.org
2012-05-09 12:54 ` manu at gcc dot gnu.org
2012-05-09 13:11 ` jgpallero at gmail dot com
2012-05-09 13:12 ` glisse at gcc dot gnu.org
2012-05-09 13:46 ` manu at gcc dot gnu.org
2012-05-09 15:17 ` jgpallero at gmail dot com
2012-05-09 15:56 ` [Bug c/53277] -Wconversion cannot handle compound expresions manu at gcc dot gnu.org
2021-07-20 17:16 ` [Bug c/53277] -Wconversion cannot handle compound expressions me at xenu dot pl
2021-07-20 17:33 ` me at xenu dot pl
2021-07-20 17:41 ` redi at gcc dot gnu.org
2021-07-20 17:42 ` pinskia at gcc dot gnu.org
2023-06-15  0:34 ` pinskia 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).