Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 31 Jan 2005 17:55:06 +0100
From:      Stefan Farfeleder <stefan@fafoe.narf.at>
To:        Ulrich Spoerlein <q@uni.de>
Cc:        Paul Richards <paul@originative.co.uk>
Subject:   Re: c99/c++ localised variable definition
Message-ID:  <20050131165504.GD78235@wombat.fafoe.narf.at>
In-Reply-To: <20050131163117.GE828@galgenberg.net>
References:  <20050131122609.GA83556@gurney.reilly.home> <90392.1107174969@critter.freebsd.dk> <20050131163117.GE828@galgenberg.net>

next in thread | previous in thread | raw e-mail | index | archive | help
On Mon, Jan 31, 2005 at 05:31:17PM +0100, Ulrich Spoerlein wrote:

> Doesn't look so:
> #include <stdlib.h>
> #include <stdio.h>
> 
> int
> main(int argc, char **argv) {
>   int N = 42;
>   int i;
>   for (int i = 0; i < N; i++)
>     if (i == 23)
>       break;
>   printf("%d\n", i);   /* use finishing index */
>   return (0);
> }
> 
> % cc -Wall -std=c99 test.c && ./a.out
> 1
> % icc -Wall -std=c99 test.c && ./a.out
> test.c(12): remark #592: variable "i" is used before its value is set
>     printf("%d\n", i);   /* use finishing index */
>                    ^

-Wshadow

Stefan



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20050131165504.GD78235>