Identical global variable declaration appearing in different translation units
Open
@pinnown is already working on this.
Since Jan 14, 2020.
- Dominant language
- C
- Stars
- 688
- Forks
- 144
- PR merge metrics
- No merged PRs in 30d
Description
t1.cpp
1 static int v = 11;
2
3 void g1()
4 {
5 v;
6 }
t2.cpp
1 static int v = 22;
2
3 void g2()
4 {
5 v;
6 }
The compiler I used parses t1.cpp and t2.cpp at once into ROSE AST. Then it takes each SgVarRefExp node (reference to 'v' at line 5) from all function body and finds its SgInitializedName node via the following pseudocode:
SgVarRefExp *ref;
SgInitializedName *name;
...
name = ref->get_symbol()->get_declaration();
It firstly obtained the correct SgInitializedName node for the 'v' declaration in t1.cpp from the 'v' reference in t1.cpp, but later from the 'v' reference in t2.cpp it wrongly got the 'v' declaration in t1.cpp.
(gdb) p ref
$8 = (SgVarRefExp *) 0x7fffe492b010
(gdb) p name
$9 = (SgInitializedName *) 0x7fffe4cca5b0
(gdb) p ref
$10 = (SgVarRefExp *) 0x7fffe492b078
(gdb) p name
$11 = (SgInitializedName *) 0x7fffe4cca5b0
Different address for 'ref', but same address for 'name'.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.