Permalink
Browse files

Enable Elf::at<T> only for POD data types

Summary:
- Make sure that the utility function Elf::at<T> only works for POD
datatypes, as it uses reinterpret_cast<T>.

Test Plan: - Unit tests

Reviewed By: simpkins@fb.com

FB internal diff: D748314
  • Loading branch information...
1 parent a6198d2 commit d7050ad5481a1a6dc958816655a4535cd2fd2df2 @pgriess pgriess committed with oyamauchi Mar 22, 2013
Showing with 2 additions and 1 deletion.
  1. +2 −1 folly/experimental/symbolizer/Elf.h
View
3 folly/experimental/symbolizer/Elf.h
@@ -123,7 +123,8 @@ class ElfFile {
void validateStringTable(const ElfW(Shdr)& stringTable) const;
template <class T>
- const T& at(off_t offset) const {
+ const typename std::enable_if<std::is_pod<T>::value, T>::type&
+ at(off_t offset) const {
return *reinterpret_cast<T*>(file_ + offset);
}

0 comments on commit d7050ad

Please sign in to comment.