Bug 632 – Typedef/enum promotions spec ambiguous - ultimate base type or lowest common denominator?

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dlang.org
Product
D
Version
D1 (retired)
Platform
All
OS
All
Creation time
2006-12-02T20:42:00Z
Last change time
2014-02-15T13:28:47Z
Keywords
spec
Assigned to
nobody
Creator
smjg
Blocks
511, 677

Comments

Comment #0 by smjg — 2006-12-02T20:42:39Z
"# If one operand is a typedef and the other is the base type of that typedef, the result is the base type. # If the two operands are different typedefs but of the same base type, then the result is that base type." By "base type", does it mean the built-in type from which the typedef is ultimately derived, or the most-derived type that is a common base to both (the lowest common denominator)? In particular, it's tempting to think that, given typedef int qwert; typedef qwert yuiop; typedef qwert asdfg; that the "base type" in question is qwert, which is the immediate parent type of yuiop and adsfg, and hence that an expression involving any two of these typedefs will promote to qwert. This is similar to the common use of "base class" in OOP lingo. The better way, IMO, is to define such promotions to be to the lowest common denominator type. Consequently, any typedef (other than one of a type that's always subject to integer promotions, but that's another matter) would be closed under arithmetic operations. I imagine that implementing this principle in the compiler wouldn't be difficult. Please see http://www.digitalmars.com/pnews/read.php?server=news.digitalmars.com&group=digitalmars.D&artnum=44821 for further commentary. But whichever method is chosen, the spec needs to be made clearer.
Comment #1 by smjg — 2008-12-31T11:27:57Z
Issue 633 has been reduced to this one. Whatever the spec is fixed to say, it must also avoid any ambiguity in what happens when mixed enum/typedef chains are involved. This will only be an issue if the ultimate base type route is chosen - going by lowest common denominator naturally addresses this.
Comment #2 by smjg — 2008-12-31T11:28:11Z
*** Bug 633 has been marked as a duplicate of this bug. ***
Comment #3 by bugzilla — 2010-11-08T14:33:58Z