| Re: 3510.0
Amazingly, the problem can be reduced to the source:
int nodeNum;
void confyyparse()
{
nodeNum = nodeNum++;
}
where the line "nodeNum = nodeNum++;" causes the problem. This line
appears as the first statement of "case 6:" in the switch statement in
confyyparse().
Although it unacceptable for the compiler to hit internal assertions, you
should do something about the line of code. Any expression that stores a
value into a variable more than once within the same "sequence point" has
undefined behavior. In other words, the expression is a programmer error
and may produce unpredictable results.
For example, assume that nodeNum has the value 0. A compiler might
evaluate the expression nodeNum = nodeNum++ by:
1. Save the old value of nodeNum
2. Increment the value of nodeNum
3. Store the value saved in step 1 into nodeNum
(nodeNum has value 0)
or by:
1. Save the old value of nodeNum
2. Store the value saved in step 1 into nodeNum
3. Increment the value of nodeNum
(nodeNum has value 1)
both are perfectly reasonable "ANSI Standard" interpretations of the
expression in question. If fact, since the program contains a programmer
error that the compiler is not obliged to diagnose, the compiler could
even do something off the wall like hit an internal assertion and die
(while permitted under the ANSI Standard, that isn't a friendly response).
I recommend that you work around the compiler assertion by either
deleting the line in question (if you want the assignment to undo the
increment) or by rewriting the line to be just "nodeNum++;" (if you want
the increment to actually happen). You might want to look at the code
generated by the previous version of the compiler to see what seemed to
work in the past.
|
| The example in .2 will cause the following warning (and no compiler crash) when
compiled with DEC C V5.6 and later on UNIX. That compiler will be available in
Digital UNIX V4.0D and later.
% cc -c t.c
cc: Warning: t.c, line 4: In this statement, the expression "nodeNum=nodeNum++"
modifies the variable "nodeNum" more than once without an intervening sequence
point. This behavior is undefined.
nodeNum = nodeNum++;
--^
These warnings are issued by the compiler used to build Digital UNIX V4.0D and
later. When it was first enabled, we found (and fixed) several areas in the UNIX
source code that relied on this undefined behavior. Fixing these warnings may
fix latent bugs that may appear later (during a port, for example).
I verified that this is still a problem in the development C++ V5.6 compiler,
but it appears to be fixed in development DEC C++ V6.0.
-Jeff
|