#41 closed defect (fixed)
Duplicate function on generic specialisation
Reported by: | Thierry Delisle | Owned by: | |
---|---|---|---|
Priority: | major | Component: | cfa-cc |
Version: | 1.0 | Keywords: | generic |
Cc: |
Description
forall( dtype T ) struct ptr_t { T * ptr; }; int foo( ptr_t( int ) p ) { return 3; } int foo( ptr_t( float ) p ) { return 4; }
yields
test.c:10:1 error: duplicate function definition for foo: function with parameters p: instance of struct ptr_t with parameters float returning _retval_foo: Attribute with name: unused signed int with body CompoundStmt Return Statement, returning: constant expression (4 4: signed int)
Change History (4)
comment:1 Changed 7 years ago by
Priority: | blocker → major |
---|
comment:2 Changed 7 years ago by
comment:3 Changed 7 years ago by
Owner: | set to Rob Schluntz <rschlunt@…> |
---|---|
Resolution: | → fixed |
Status: | new → closed |
In e35f30a:
comment:4 Changed 7 years ago by
I managed to get this to work by following the last approach (unconditionally mangling type parameters) and adding an extra mode that never mangles type parameters (which only needed to be used in one place related to constructors). Thanks for the tips!
Note: See
TracTickets for help on using
tickets.
I looked a little closer at this, didn't manage to solve it, but here's a bit more information:
typeMode
, it includes the type parameters of generic types, otherwise it does not. The Indexer call to the Mangler is not intypeMode
, and putting it intotypeMode
breaks other things, as does having the Mangler unconditionally mangle type parameters. This ought to be fixed, but it has non-trivial interactions with the rest of the compiler, and I have deja vu about trying to fix this before and failing.