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

Partial fix for 13761 - Fix code which triggers warnings #4174

Closed
wants to merge 10 commits into from
Closed

Partial fix for 13761 - Fix code which triggers warnings #4174

wants to merge 10 commits into from

Conversation

Temtaime
Copy link
Contributor

@bearophile
Copy link

Many indentations of your changes are messed up. (A possible solution: set your editor to automatically convert tabs to 4 spaces, and try again).

@Temtaime
Copy link
Contributor Author

Thanks, fixed.

@@ -2343,7 +2343,10 @@ void FuncDeclaration::buildResultVar(Scope *sc, Type *tret)
{
if (!vresult)
{
Loc loc = fensure ? fensure->loc : loc;
Copy link
Contributor

Choose a reason for hiding this comment

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

If fensure is NULL, the local loc should be initialized by this->loc.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

C++ unlike D accepts code like:
int a = false ? 1 : a;
and a will be uninitialized
Then it was a logic error in the original code.

se = (StringExp *)e->copy();
copied = 1;
Copy link
Contributor

Choose a reason for hiding this comment

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

All copied = 1; are immediately after the copy() call and they're consistent. Removing some assignments would optimize code a little but it would be unkind for humans. keep them as-is.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

After these copied = 1 there is a jump to Lcast which returns and there « copied » are not used.
Are you sure that we must keep these copied ?

Copy link
Contributor

Choose a reason for hiding this comment

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

I know those assignments are currently redundant. But if we modify/refactor this function and the code flow would be changed, copied = 1 might be required again. In my thought those redundant lines are necessary for the code robustness.

@Temtaime
Copy link
Contributor Author

Yes sorry for mistakes now all seems to be right.

@@ -425,7 +429,7 @@ int File::exists()
void File::remove()
{
#if POSIX
int dummy = ::remove(this->name->toChars());
Copy link
Member

Choose a reason for hiding this comment

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

No, this needs to stay as-is to work around a limitation of the ddmd conversion tool.

@9rnsr
Copy link
Contributor

9rnsr commented Nov 29, 2014

I approved testing this PR in the auto-tester. Please rebase commits on git-head master.

{
assert(t1 && t2);

if(t1->Tty == TYdouble && t2->Tty == TYdouble)
Copy link
Member

Choose a reason for hiding this comment

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

What if t2 is null and t1->Tty is not TYdouble? It previously wouldn't crash, but now it will assert.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Is it possible ?
OK if so I corrected it.

@ghost ghost changed the title Partial fix for #13761. Partial fix for 13761 - Fix code which triggers warnings Dec 6, 2014
@WalterBright
Copy link
Member

Will pull once it is mergable.

@johto johto mentioned this pull request Dec 28, 2014
@schveiguy
Copy link
Member

Note, in #4239, the func.c issue at least is fixed.

@@ -1529,8 +1531,6 @@ elem *toElem(Expression *e, IRState *irs)
}
else
{
d_uns64 elemsize = sd->size(ne->loc);
Copy link
Member

@ibuclaw ibuclaw Dec 30, 2017

Choose a reason for hiding this comment

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

Note, this is needed for the side effect, even though the variable is unused. If memory serves correctly.

@Temtaime Temtaime closed this Dec 30, 2017
@Temtaime
Copy link
Contributor Author

Outdated and fixed by other prs

@ibuclaw
Copy link
Member

ibuclaw commented Dec 30, 2017

For sure now the majority of sources are converted to D, static analysis can no longer be done on the sources.

I will ignore most of the asserts here, I don't think any of them are actual bugs. There are still a few unmerged C source changes, and I did spot some logic bugs in the D code too.

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