I am working on some outdated code, and I came across something that I am not sure is safe - in fact, I am sure it is undefined, but I'm not quite sure why (more or less bad feeling).
For some reason, this code has a class, we will call it A. Class A has an overloaded pre-increment (++) operator, which seems to perform some operations on the value of the pointer it contains (we, ll call this pointer B)
I found a function call in which the user goes to A, and a copy of the link to pointer B with the link removed when using the overloaded pre-increment operator.
foo(++A, *B);
Since the pre-increment changes the value pointed to by B, and B is dereferenced and used as a parameter in the same call ... is there a problem or should I just leave it that way?
Sorry if this sounds confusing - the code is too complicated to insert, but I did my best to explain the situation. If necessary, I will make some fake code representing the situation, but I hope this will be clear.
In addition, I know that this poor design for this code is passed in a parameter already contained in a separate one, but I would like to understand if this is a problem.
source share