Skip to content

Use memcpy instead of *(int)*&#115

Open
Garfield1002 wants to merge 1 commit intoopengl-tutorials:gh-pagesfrom
Garfield1002:patch-1
Open

Use memcpy instead of *(int)*&#115
Garfield1002 wants to merge 1 commit intoopengl-tutorials:gh-pagesfrom
Garfield1002:patch-1

Conversation

@Garfield1002
Copy link

The issues with *(int)*& are that

  • It is quite confusing (especially for C++ beginners)
  • In this case, it is a strict aliasing violation

A solution can therefore be to replace it with memcpy

I am only making a single PR, but this change (if approved) probably needs to be made in other locations.

This PR comes after a question I asked on StackOverflow

The issues with  `*(int)*&` are that
- It is quite confusing (especially for C++ beginners)
- In this case, it is a strict aliasing violation

A solution can therefore be to replace it with `memcpy`

_This PR comes after a question I asked on [StackOverflow](https://stackoverflow.com/questions/68699806/strange-c-type-casting)_
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant