Re: Help wanted on some source codes
- From: "slebetman@xxxxxxxxx" <slebetman@xxxxxxxxx>
- Date: 29 Nov 2005 18:34:15 -0800
Old Wolf wrote:
> Becker wrote:
>
> > 1.===========================================
> > /* a.c */
> > int x;
> > int y;
> >
> > void main()
> > {
> > f();
> > printf("%x %x\n", x, y);
> > }
> >
> > /* b.c */
> > double x;
> >
> > void f()
> > {
> > x = -0.0;
> > }
>
> All of your programs have undefined behaviour because there
> are two variables called 'x' with external linkage.
>
The programs are rubbish of course. But wouldn't the file scope of x
mean that function f() is actually refering to the double x instead of
the int x?
.
- Follow-Ups:
- Re: Help wanted on some source codes
- From: Flash Gordon
- Re: Help wanted on some source codes
- From: Skarmander
- Re: Help wanted on some source codes
- From: Jack Klein
- Re: Help wanted on some source codes
- References:
- Help wanted on some source codes
- From: Becker
- Re: Help wanted on some source codes
- From: Old Wolf
- Help wanted on some source codes
- Prev by Date: Re: Help wanted on some source codes
- Next by Date: Re: Help wanted on some source codes
- Previous by thread: Re: Help wanted on some source codes
- Next by thread: Re: Help wanted on some source codes
- Index(es):
Relevant Pages
|