Opened 5 years ago
Last modified 5 years ago
#183 new defect
Polymorphic Variable Name Reuse Causes Crash
| Reported by: | ajbeach | Owned by: | |
|---|---|---|---|
| Priority: | minor | Component: | cfa-cc |
| Version: | 1.0 | Keywords: | |
| Cc: |
Description
It appears that polymorphic variables are being confused. The following code works however if you replace occurrences of the name "Tx" with "T" the compiler segfaults.
trait satifies(dtype Tx) {
void assertion(Tx &);
};
forall(dtype T)
struct Wrapper {};
forall(dtype T | satifies(Wrapper(T)))
T & function(T & value) {
return value;
}
It appears somehow T=Wrapper(T) is causing a problem. Even if that actual equation is not used, it might be the mangling from one is applied to the other or something else. It does appear to lead to a segmentation fault during validation due to stack overflow.
Change History (2)
comment:1 by , 5 years ago
| Priority: | major → minor |
|---|
comment:2 by , 5 years ago
I may have found an even simpler example, just replace Wrapper(T) with T *. Once again this is the working code, rename Tx to T to get the crash.
trait satisfies(dtype Tx) {
void assertion(Tx);
};
forall(dtype T | satisfies(T *))
void something(T * value) {
assertion(value);
}
Dropping it down to minor because if you use different variable names it should all be fine.