public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/35957] New: static return value type checking, no warning issued
@ 2008-04-16 11:18 clemens dot kol at gmx dot at
2008-04-16 11:28 ` [Bug c/35957] " rguenth at gcc dot gnu dot org
0 siblings, 1 reply; 2+ messages in thread
From: clemens dot kol at gmx dot at @ 2008-04-16 11:18 UTC (permalink / raw)
To: gcc-bugs
I hope this does not conflict with the C-standard, but why does the following
code not issue a warning about the return value of 'someFunction'?
#include <stdio.h>
unsigned int someFunction() { return 0xbadc0de; }
void someOtherFunction(unsigned char in) { printf("0x%x\n", in); }
int main(int argc, char **argv)
{
unsigned char x;
unsigned int y;
x = someFunction();
printf("0x%x\n", x);
y = 0xbadc0de;
someOtherFunction(y);
return 0;
}
The return value is correctly cast to a char, but shouldn't the compiler
complain?
--
Summary: static return value type checking, no warning issued
Product: gcc
Version: 4.2.2
Status: UNCONFIRMED
Severity: minor
Priority: P3
Component: c
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: clemens dot kol at gmx dot at
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35957
^ permalink raw reply [flat|nested] 2+ messages in thread
* [Bug c/35957] static return value type checking, no warning issued
2008-04-16 11:18 [Bug c/35957] New: static return value type checking, no warning issued clemens dot kol at gmx dot at
@ 2008-04-16 11:28 ` rguenth at gcc dot gnu dot org
0 siblings, 0 replies; 2+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2008-04-16 11:28 UTC (permalink / raw)
To: gcc-bugs
------- Comment #1 from rguenth at gcc dot gnu dot org 2008-04-16 11:27 -------
Not unconditionally. With -Wconversion it does since gcc 4.3:
t.c: In function 'main':
t.c:11: warning: conversion to 'unsigned char' from 'unsigned int' may alter
its value
t.c:15: warning: conversion to 'unsigned char' from 'unsigned int' may alter
its value
--
rguenth at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution| |FIXED
Target Milestone|--- |4.3.0
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35957
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2008-04-16 11:28 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-04-16 11:18 [Bug c/35957] New: static return value type checking, no warning issued clemens dot kol at gmx dot at
2008-04-16 11:28 ` [Bug c/35957] " rguenth at gcc dot gnu dot 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).