Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue 14950 - Setting enum value to the last member of another enum causes int overflow error #5006

Merged
merged 1 commit into from Sep 1, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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
}