#1644 bigunsignedint: ambiguous overload for bigunsignedint(unsigned long)
Metadata
Property | Value |
---|---|
Reported by | Ansgar Burchardt (burchardt@igpm.rwth-aachen.de) |
Reported at | May 8, 2015 13:18 |
Type | Bug Report |
Version | Git (pre2.4) [autotools] |
Operating System | Unspecified / All |
Last edited by | Steffen Müthing (steffen.muething@iwr.uni-heidelberg.de) |
Last edited at | May 11, 2015 17:21 |
Closed by | Steffen Müthing (steffen.muething@iwr.uni-heidelberg.de) |
Closed at | May 11, 2015 17:21 |
Closed in version | Unknown |
Resolution | Fixed |
Comment | Merged to master in 4c79a64 and backported to release branch in b0287a9. |
Thanks, Ansgar! |
Description
The following code from YaspGrid fails to compile on i386 where size_t == int == int32_t, unsigned long == uint64_t:
+--- | dune/grid/yaspgrid/yaspgridentity.hh:338:52: error: call of overloaded 'bigunsignedint(long unsigned int)' is ambiguous | PersistentIndexType id(_it.shift().to_ulong()); +---[ https://buildd.debian.org/status/fetch.php?pkg=dune-grid&arch=i386&ver=2.4~20150506gd3c1350-1&stamp=1431044142 ]
PersistentIndexType is Dune::bigunsignedint<80> which has two constructors that could be called:
- bigunsignedint(std::size_t x) (== unsigned int)
- bigunsignedint(int y)
Both involve converting the "unsigned long" to a shorter type -> ambiguous overload.
I also noticed that the constructor taking an "int" does (for me) unexpected things:
+--- | template | bigunsignedint::bigunsignedint (int y) | { | std::size_t x = std::abs(y); | assign(x); | } +---
I really wouldn't expect "bigunsignedint(-42)" to be equivalent to "bigunsignedint(42)"...
I would like to replace the constructor taking an "size_t" with one taking "uintmax_t" (since C++11, though C introduced it earlier). I also think the constructor taking an "int" should be deprecated.
As an unrelated change I would like to replace "unsigned short" with "uint16_t" in this class (also a C++11 type). (C++ doesn't require "unsigned short" to be "uint16_t", but the code here does.)
Ansgar