-
Notifications
You must be signed in to change notification settings - Fork 15.1k
Closed
Labels
Description
This bit of code looks a bit suspect:
llvm-project/openmp/libompd/src/TargetValue.h
Lines 232 to 252 in 24a39f3
| template <typename T> ompd_rc_t TBaseValue::getValue(T &buf) { | |
| assert(sizeof(T) >= baseTypeSize); | |
| ompd_rc_t ret = getValue(&buf, 1); | |
| if (sizeof(T) > baseTypeSize) { | |
| switch (baseTypeSize) { | |
| case 1: | |
| buf = (T) * ((int8_t *)&buf); | |
| break; | |
| case 2: | |
| buf = (T) * ((int16_t *)&buf); | |
| break; | |
| case 4: | |
| buf = (T) * ((int32_t *)&buf); | |
| break; | |
| case 8: | |
| buf = (T) * ((int64_t *)&buf); | |
| break; | |
| } | |
| } | |
| return ret; | |
| } |
This passes in T& buf, then reads into it via getValue() -- this part is fine, as that's essentially done via memcpy.
But then buf is cast to uintN_t *, dereferenced, cast to T and written back to buf. This is not compatible with strict aliasing in C.