Skip to content

Commit

Permalink
Merge pull request #5006 from 9rnsr/fix14950
Browse files Browse the repository at this point in the history
Issue 14950 - Setting enum value to the last member of another enum causes int overflow error
  • Loading branch information
yebblies committed Sep 1, 2015
2 parents 1857062 + 061ac36 commit 2748404
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/denum.d
Expand Up @@ -656,7 +656,8 @@ public:
e = e.ctfeInterpret();
if (e.toInteger())
{
error("initialization with (%s.%s + 1) causes overflow for type '%s'", emprev.ed.toChars(), emprev.toChars(), ed.type.toBasetype().toChars());
error("initialization with (%s.%s + 1) causes overflow for type '%s'",
emprev.ed.toChars(), emprev.toChars(), ed.memtype.toChars());
goto Lerrors;
}
// Now set e to (eprev + 1)
Expand Down
18 changes: 18 additions & 0 deletions test/fail_compilation/diag14950.d
@@ -0,0 +1,18 @@
/*
TEST_OUTPUT:
---
fail_compilation/diag14950.d(17): Error: enum member diag14950.B.end initialization with (B.start + 1) causes overflow for type 'A'
---
*/

enum A
{
start,
end
}

enum B
{
start = A.end,
end
}

0 comments on commit 2748404

Please sign in to comment.