forked from OSchip/llvm-project
[flang] Replace access through union with reinterpret_cast.
This avoids undefined behaviour. Original-commit: flang-compiler/f18@e289bbfa83 Reviewed-on: https://github.com/flang-compiler/f18/pull/767 Tree-same-pre-rewrite: false
This commit is contained in:
parent
5e86f88937
commit
c579118ce6
|
@ -129,23 +129,13 @@ template<typename TR, typename... ArgInfo> struct CallableHostWrapper {
|
|||
template<typename TR, typename... TA>
|
||||
inline GenericFunctionPointer ToGenericFunctionPointer(
|
||||
FuncPointer<TR, TA...> f) {
|
||||
union {
|
||||
GenericFunctionPointer gp;
|
||||
FuncPointer<TR, TA...> fp;
|
||||
} u;
|
||||
u.fp = f;
|
||||
return u.gp;
|
||||
return reinterpret_cast<GenericFunctionPointer>(f);
|
||||
}
|
||||
|
||||
template<typename TR, typename... TA>
|
||||
inline FuncPointer<TR, TA...> FromGenericFunctionPointer(
|
||||
GenericFunctionPointer g) {
|
||||
union {
|
||||
GenericFunctionPointer gp;
|
||||
FuncPointer<TR, TA...> fp;
|
||||
} u;
|
||||
u.gp = g;
|
||||
return u.fp;
|
||||
return reinterpret_cast<FuncPointer<TR, TA...>>(g);
|
||||
}
|
||||
|
||||
template<typename TR, typename... ArgInfo>
|
||||
|
|
|
@ -35,7 +35,7 @@ class FoldingContext;
|
|||
using TypeCode = unsigned char;
|
||||
|
||||
template<typename TR, typename... TA> using FuncPointer = TR (*)(TA...);
|
||||
using GenericFunctionPointer = FuncPointer<void *>;
|
||||
using GenericFunctionPointer = void (*) (void);
|
||||
|
||||
enum class PassBy { Ref, Val };
|
||||
template<typename TA, PassBy Pass = PassBy::Ref> struct ArgumentInfo {
|
||||
|
|
Loading…
Reference in New Issue