Bug 69 – dstress.run.a.assert_13_A/B

Status
RESOLVED
Resolution
INVALID
Severity
minor
Priority
P3
Component
tools
Product
D
Version
D2
Platform
All
OS
All
Creation time
2006-03-24T01:52:00Z
Last change time
2015-06-09T05:15:00Z
Assigned to
braddr
Creator
bugs-d

Comments

Comment #0 by bugs-d — 2006-03-24T01:52:12Z
The tests on DStress labeled "assert_13_A" and "assert_13_B" are categorized under run, but I believe this is incorrect. The grammar here: http://www.digitalmars.com/d/expression.html#AssertExpression Does specify that any expression (not just AssignExpressions) is valid, but it also seems reasonably clear that it should be a boolean. Were D changed to support Expressions instead of AssignExpressions here, it would cause the following error: assert_13_A.d(12): expression "\u00aa" , "\u00aa\uff16" of type char[5] does not have a boolean value As such, I believe the code should either be changed: assert("\u00aa", "\u00aa\uff16", true); Or it should be recategorized under "compile" (whichever is simpler.) -[Unknown]
Comment #1 by thomas-dloop — 2006-03-26T05:30:02Z
http://www.digitalmars.com/d/expression.html#AssertExpression AssertExpression: assert ( Expression ) "Asserts evaluate the expression. If the result is false, an AssertError is thrown. If the result is true, then no exception is thrown." http://www.digitalmars.com/d/type.html "Casting an expression to bool means testing for 0 or !=0 for arithmetic types, and null or !=null for pointers or references." As such "assert(null);" and "assert("abc");" are legal. Expression: AssignExpression AssignExpression , Expression "It is an error if the expression contains any side effects that the program depends on." doesn't apply as the program isn't influenced by the assignment to s. Thus assert_13_B - "assert(s = "abc", "cde");" - is legal. assert_13_A - "assert("abc", "cde");" - is a tricky one. A CharacterLiteral (in this case "abc") is a PrimaryExpression. A PrimaryExpression is a PostfixExpression. A PostfixExpression is an UnaryExpression. An UnaryExpression is a MulExpression. A MulExpression is an AddExpression. An AddExpression is a ShiftExpression. A ShiftExpression is a RelExpression. A RelExpression is an EqualExpression. An EqualExpression is an AndExpression. An AndExpression is a XorExpression. A XorExpression is an OrExpression. An OrExpression is a AndAndExpression, An AndAndExpression is an OrOrExpression. An OrOrExpression is a ConditionalExpression. A ConditionalExpression is an AssignExpression. It follows: "abc" is an AssignExpression. Thus "assert("abc", "def");" matches the "assert(AssignExpression , Expression);" pattern and as a consequence matches the assert definition: "assert(Expression);". assert_13_A is legal D.