User forums > Help

Codeblocks showing wrong output with memmove().

<< < (2/2)

Gobtotem:

--- Quote from: Krice on November 28, 2018, 01:58:19 pm ---There is no need to write code like that, because if it sounds like undefined behavior, it's going to be it at least with compiler optimizations.

--- End quote ---
Don't know what you think is the undefined behavior or else but the bug has been confirmed by gcc and even fixed by gcc.
Here is the bug report if you want to take a look btw:- https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88223

BlueHazzard:

--- Quote ---There is no need to write code like that, because if it sounds like undefined behavior
--- End quote ---
from c++ reference:

--- Quote ---Copying takes place as if an intermediate buffer were used, allowing the destination and source to overlap.
--- End quote ---
So this operation should be fine...

Krice:
The point is that when you try to do funny stuff then random things happen. On the other hand if you write working code then the programs could also work as they should.

raynebc:
The better point is memmove was not following its clearly defined behavior.  If a function doesn't work as documented, it can't be counted on to be used.

Navigation

[0] Message Index

[*] Previous page

Go to full version