Relative Content

Tag Archive for cgcc

memcpy() behaviour different depending on pointer cast

I’ve been having trouble for hours now while trying to compare 2 seemingly identical structs. I’ve looked into alignment and padding as possible issues but found no issues. When I played around with different combinations of designated initialisation and zero initialisation combined with strcpy() I found that memcpy() returned either 1 or 0. I hope I’ve finally narrowed down the problem into a single C file.

Compile result different in GCC 13.1 and GCC 13.2 constructing a string

I have the following code that compiles fine on GCC 13.2. Colleagues can’t compile it on GCC 13.1. The new version compiles fine even with -Wall -Wextra. I assume that GCC 13.2 is better and more correct. Which change made this possible? Why is this call not ambiguous when it was considered ambiguous before?