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

D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 632 - Typedef/enum promotions spec ambiguous - ultimate base type or lowest common denominator?
Summary: Typedef/enum promotions spec ambiguous - ultimate base type or lowest common ...
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dlang.org (show other issues)
Version: D1 (retired)
Hardware: All All
: P2 normal
Assignee: No Owner
URL: http://www.digitalmars.com/d/type.html
Keywords: spec
: 633 (view as issue list)
Depends on:
Blocks: 511 677
Show dependency tree / graph
Reported: 2006年12月02日 20:42 UTC by Stewart Gordon
Modified: 2014年02月15日 13:28 UTC (History)
1 user (show)

See Also:


Attachments
Add an attachment (proposed patch, testcase, etc.)

Note You need to log in before you can comment on or make changes to this issue.
Description Stewart Gordon 2006年12月02日 20:42:39 UTC
"# 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 Stewart Gordon 2008年12月31日 11:27:57 UTC
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 Stewart Gordon 2008年12月31日 11:28:11 UTC
*** Bug 633 has been marked as a duplicate of this bug. ***
Comment 3 Walter Bright 2010年11月08日 14:33:58 UTC
http://www.dsource.org/projects/phobos/changeset/2137 


AltStyle によって変換されたページ (->オリジナル) /