* Warning when passing int, but unsigned int is awaited?
@ 2008-02-13 16:04 Rene Perlberg
2008-02-13 16:12 ` John Love-Jensen
0 siblings, 1 reply; 6+ messages in thread
From: Rene Perlberg @ 2008-02-13 16:04 UTC (permalink / raw)
To: gcc-help
Hello everyone,
following scenario:
void func(unsigned int _u)
{
//do a lot of stuff
}
int main()
{
int i = -1;
func(i);
return 0;
}
Is there any way to make the compiler write a warning or an error, when an int is passed to a function which awaits an unsigned int? I tried some of the options gcc gives the user, but nothing worked for me.
I'm using gcc, version 4.1.3 20070929.
Best regards.
--
Ist Ihr Browser Vista-kompatibel? Jetzt die neuesten
Browser-Versionen downloaden: http://www.gmx.net/de/go/browser
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Warning when passing int, but unsigned int is awaited?
2008-02-13 16:04 Warning when passing int, but unsigned int is awaited? Rene Perlberg
@ 2008-02-13 16:12 ` John Love-Jensen
2008-02-13 16:26 ` Rene Perlberg
0 siblings, 1 reply; 6+ messages in thread
From: John Love-Jensen @ 2008-02-13 16:12 UTC (permalink / raw)
To: Rene Perlberg, MSX to GCC
Hi Rene,
> Is there any way to make the compiler write a warning or an error, when an int
> is passed to a function which awaits an unsigned int? I tried some of the
> options gcc gives the user, but nothing worked for me.
Try: -Wconversion
HTH,
--Eljay
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Warning when passing int, but unsigned int is awaited?
2008-02-13 16:12 ` John Love-Jensen
@ 2008-02-13 16:26 ` Rene Perlberg
2008-02-13 16:52 ` John Love-Jensen
0 siblings, 1 reply; 6+ messages in thread
From: Rene Perlberg @ 2008-02-13 16:26 UTC (permalink / raw)
To: John Love-Jensen, gcc-help
-------- Original-Nachricht --------
> Datum: Wed, 13 Feb 2008 10:11:53 -0600
> Von: John Love-Jensen <eljay@adobe.com>
> An: Rene Perlberg <Perle5000@gmx.de>, MSX to GCC <gcc-help@gcc.gnu.org>
> Betreff: Re: Warning when passing int, but unsigned int is awaited?
> Hi Rene,
>
> > Is there any way to make the compiler write a warning or an error, when
> an int
> > is passed to a function which awaits an unsigned int? I tried some of
> the
> > options gcc gives the user, but nothing worked for me.
>
> Try: -Wconversion
Hey Eljay,
I forgot to tell, that I already tried some options, which are -Wall -Wextra -pedantic and also -Wconversion, but none of these worked for me.
Maybe it is intended by gcc not to give a warning, because it is c++ standard to make an implicite conversion?
Regards, PiJ.
--
GMX FreeMail: 1 GB Postfach, 5 E-Mail-Adressen, 10 Free SMS.
Alle Infos und kostenlose Anmeldung: http://www.gmx.net/de/go/freemail
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Warning when passing int, but unsigned int is awaited?
2008-02-13 16:26 ` Rene Perlberg
@ 2008-02-13 16:52 ` John Love-Jensen
2008-02-13 21:06 ` Robert William Fuller
0 siblings, 1 reply; 6+ messages in thread
From: John Love-Jensen @ 2008-02-13 16:52 UTC (permalink / raw)
To: Rene Perlberg, MSX to GCC
Hi Rene,
It works on my compiler. Using C.
I think the -Wconversion feature was busted (perhaps still is busted) for
C++. I vaguely recall that someone (one of the developers of GCC itself)
mentioned that before, on this forum. And that there was a bug filed on it
already.
Try GCC 4.2.3, or if you are in a daring mood GCC 4.3.0.
HTH,
--Eljay
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Warning when passing int, but unsigned int is awaited?
2008-02-13 16:52 ` John Love-Jensen
@ 2008-02-13 21:06 ` Robert William Fuller
2008-02-13 23:58 ` James Tebneff
0 siblings, 1 reply; 6+ messages in thread
From: Robert William Fuller @ 2008-02-13 21:06 UTC (permalink / raw)
To: John Love-Jensen; +Cc: Rene Perlberg, MSX to GCC
John Love-Jensen wrote:
> It works on my compiler. Using C.
It works for some value of work on gcc-4.1.2. It reports on things that
clearly have no width difference. Am I detecting a theme with these
less used compiler warnings? (Note that -Wunreachable-code reports
erroneously as well.)
> I think the -Wconversion feature was busted (perhaps still is busted) for
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Warning when passing int, but unsigned int is awaited?
2008-02-13 21:06 ` Robert William Fuller
@ 2008-02-13 23:58 ` James Tebneff
0 siblings, 0 replies; 6+ messages in thread
From: James Tebneff @ 2008-02-13 23:58 UTC (permalink / raw)
To: Robert William Fuller; +Cc: John Love-Jensen, Rene Perlberg, MSX to GCC
On Feb 14, 2008 7:36 AM, Robert William Fuller
<hydrologiccycle@gmail.com> wrote:
> John Love-Jensen wrote:
> > It works on my compiler. Using C.
>
> It works for some value of work on gcc-4.1.2. It reports on things that
> clearly have no width difference. Am I detecting a theme with these
> less used compiler warnings? (Note that -Wunreachable-code reports
> erroneously as well.)
>
>
> > I think the -Wconversion feature was busted (perhaps still is busted) for
>
>
Hi,
I was under the impression that this feature is being worked on currently.
http://gcc.gnu.org/wiki/NewWconversion
Regards,
JT
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2008-02-13 23:58 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-02-13 16:04 Warning when passing int, but unsigned int is awaited? Rene Perlberg
2008-02-13 16:12 ` John Love-Jensen
2008-02-13 16:26 ` Rene Perlberg
2008-02-13 16:52 ` John Love-Jensen
2008-02-13 21:06 ` Robert William Fuller
2008-02-13 23:58 ` James Tebneff
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).