D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 3302 - Sloppy type check in dynamic initialization of struct
Summary: Sloppy type check in dynamic initialization of struct
Status: RESOLVED DUPLICATE of issue 3259
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All All
: P2 critical
Assignee: No Owner
URL:
Keywords: accepts-invalid
Depends on:
Blocks:
 
Reported: 2009-09-05 19:14 UTC by HOSOKAWA Kenchi
Modified: 2015-06-09 01:26 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description HOSOKAWA Kenchi 2009-09-05 19:14:18 UTC
struct S { int a; }
struct T { real a=2; }
T t;
S s = t; // no compile-time or runtime error 
std.stdio.writeln(s.a); // -> 0


Probably this issue is due to excess-optimization.
The issue is highly critical because it leave a kind of difficult-to-find problem in the compiled binary.

Besides, strong-typed enum work well.


enum E { a }
enum F { a }
E e = F.a; // of course compile-time error!


P.S.
Is this a duplicate of another reported issue?
Comment 1 HOSOKAWA Kenchi 2009-09-05 19:20:39 UTC

*** This issue has been marked as a duplicate of issue 3259 ***