Export to GitHub

picoc - issue #201

Variable scope not always respected


Posted on Jan 30, 2015 by Helpful Monkey

What steps will reproduce the problem?

picoc> while(1) { > int e = getchar(); > if(e == 0x20) break; > } f d t

picoc> int e; ^ :5: 'e' is already defined

What is the expected output? What do you see instead? Variable "e" should have no meaning outside of the while() block, however, it is still defined when execution continues past the block.

What version of the product are you using? On what operating system? This happens both on v2.1 and on r608, both on x86-64 Linux 3.14 with GCC 4.8.2, and on a platform with SH4 CPU I'm porting PicoC to (with great success), and for which I cross-compile using GCC 4.8.2 too.

Please provide any additional information below. This also appears to happen with if blocks, and probably with for blocks too...

picoc> if(1) { > int a = 6; > } > int a; ^ :4: 'a' is already defined picoc>

Status: New

Labels:
Type-Defect Priority-Medium