Skip to content

Fix issue 16244 - Prevent an ICE with empty cast#6457

Merged
WalterBright merged 1 commit intodlang:masterfrom
LemonBoy:b16244
Jun 14, 2017
Merged

Fix issue 16244 - Prevent an ICE with empty cast#6457
WalterBright merged 1 commit intodlang:masterfrom
LemonBoy:b16244

Conversation

@LemonBoy
Copy link
Contributor

No description provided.

@dlang-bot
Copy link
Contributor

Fix Bugzilla Description
16244 compiler ICE on complex typeof() for method arg type

@UplinkCoder
Copy link
Member

UplinkCoder commented Jan 21, 2017

This looks okay.

visit(cast(UnaExp)e);
if (!result)
// e.to can be null for `cast()`
if (!result && e.to)
Copy link
Member

Choose a reason for hiding this comment

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

e.error here ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hm? A cast with no type is semantically valid albeit just a no-op

Copy link
Member

Choose a reason for hiding this comment

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

then maybe we can warn ?
uint a = cast()12;
does indeed compile but I feel it's strange to allow that

@UplinkCoder
Copy link
Member

@LemonBoy where does it say that an empty cast is semantically valid ?

@dnadlinger
Copy link
Contributor

@UplinkCoder: Grammatically, it is valid as per the second clause of CastExpression, and the semantics (remove any type modifiers) are documented in the spec.

@UplinkCoder
Copy link
Member

@klickverbot I'd say we should fix the spec then this makes no sense what-so-ever.

@dnadlinger
Copy link
Contributor

@UplinkCoder: It's quite useful to cast away const/shared/…, and there on purpose. Just because you don't know a part of the language doesn't mean it "makes no sense what-so-ever".

@UplinkCoder
Copy link
Member

@klickverbot then it is not a no-op. but rather a buitin cast-to-unqual.

@dnadlinger
Copy link
Contributor

then it is not a no-op. but rather a buitin cast-to-unqual.

Indeed – I was just replying to your question, and missed @LemonBoy's no-op suggestion.

@LemonBoy
Copy link
Contributor Author

Rebased, the DAutoTest failure looks unrelated.
Can we somehow get this merged?

@UplinkCoder
Copy link
Member

@andralex this is ready.

@WalterBright WalterBright merged commit e797f7e into dlang:master Jun 14, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants