Re: Help wanted on some source codes



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?

.



Relevant Pages