delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/03/01/09:27:09

Message-ID: <8D53104ECD0CD211AF4000A0C9D60AE35C1EB7@probe-2.acclaim-euro.net>
From: Shawn Hargreaves <ShawnH AT Probe DOT co DOT uk>
To: djgpp AT delorie DOT com
Subject: Re: BUG
Date: Mon, 1 Mar 1999 12:24:26 -0000
MIME-Version: 1.0
X-Mailer: Internet Mail Service (5.0.1460.8)
Reply-To: djgpp AT delorie DOT com

Carlos Giani_AEN2003 (M2003) writes:
> Here's an example program:
> 
> #include <stdio.h>
> #include <conio.h>
> int main(void)
> {
>   int x;
>   int y;
>   
>   x = 0;
>   
>   y = (x) ? 1 : 2;  /* y will ALWAYS be 1 (this is the BUG!) */
>   
>   printf("%i\n",y);
>   
>   getch();
> }
> 
> I use RHIDE and GCC 2.8.1

This works correctly for me. Using gcc 2.8.1, I compile it with the
options "gcc -O3 -Wall test.c -o test.exe", which gives the warning:

   test.c: In function `main':
   test.c:12: warning: control reaches end of non-void function

You should fix that by returning something sensible (eg. zero) at
the end of main(), but that is just a detail. Apart from this,
your code works exactly as it should, and prints 2. What options 
do you use to compile it? Exactly what compiler packages did you
install?


	Shawn Hargreaves.

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019