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

add size() checks to declaration.d #6065

Merged
merged 1 commit into from Aug 22, 2016

Conversation

WalterBright
Copy link
Member

Protect against size() failures and divide-by-zero. Not sure if any of these could happen, but added asserts to be sure.

@WalterBright WalterBright force-pushed the size-declaration.d branch 2 times, most recently from 635c46e to 3db6b13 Compare August 14, 2016 23:34
@codecov-io
Copy link

Current coverage is 81.95% (diff: 100%)

Merging #6065 into master will decrease coverage by 5.46%

@@             master      #6065   diff @@
==========================================
  Files            96         96           
  Lines         55797      55776     -21   
  Methods           0          0           
  Messages          0          0           
  Branches          0          0           
==========================================
- Hits          48774      45709   -3065   
- Misses         7023      10067   +3044   
  Partials          0          0           

Powered by Codecov. Last update 5146e5f...635c46e

@wilzbach
Copy link
Member

wilzbach commented Aug 14, 2016

  • Hits 48774 45709 -3065
  • Misses 7023 10067 +3044
    Partials 0 0

Huh?
Seems like we are sending the reports despite an error happened in the testsuite :/

const vsz = v.type.size();
const tsz = type.size();
assert(vsz != SIZE_INVALID && tsz != SIZE_INVALID);
return ( offset < v.offset + vsz &&
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

odd spaces after paren

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also: return (expr); is an unrecommended (we should use a style rule to automatically reject it), use return expr;

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The spaces are to line things up with the next line. I removed the parens.

@@ -976,7 +976,7 @@ public:
{
// Bugzilla 13776: Don't use ti->toAlias() to avoid forward reference error
// while printing messages.
TemplateInstance ti = t.sym.parent.isTemplateInstance();
TemplateInstance ti = t.sym.parent ? t.sym.parent.isTemplateInstance() : null;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks unnecessary.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is. It crashes otherwise.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It crashes otherwise.

It does indeed

@AndrejMitrovic
Copy link
Contributor

Auto-merge toggled on

@AndrejMitrovic AndrejMitrovic merged commit 72aaad1 into dlang:master Aug 22, 2016
@ibuclaw
Copy link
Member

ibuclaw commented Mar 25, 2017

This caused a regression.

https://issues.dlang.org/show_bug.cgi?id=17275

return null;

const sz = type.size();
assert(sz != SIZE_INVALID);
Copy link
Member

@wilzbach wilzbach May 29, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apparently the sz can have an invalid size: https://issues.dlang.org/show_bug.cgi?id=17451

@WalterBright WalterBright deleted the size-declaration.d branch May 29, 2017 08:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
7 participants