Skip to content

Commit

Permalink
caffe2: fix gcc8 warnings
Browse files Browse the repository at this point in the history
Summary:
The warnings are erroneous as far as i can see,
so tweak things to avoid. The (unsigned int) cast is
to avoid passing -1 to a size_t time.  This was triggered
in gcc8's lto build only, giving:

  caffe2/aten/src/TH/generic/THTensor.cpp: In function ‘THFloatTensor_squeeze1d’:
  lto1: error: ‘__builtin_memset’ specified size 18446744073709551608
  exceeds maximum object size 9223372036854775807 [-Werror=stringop-overflow=]
  In function ‘newImpl’,
    inlined from ‘operator new’ at common/memory/OperatorOverride.cpp:86:23,
    inlined from ‘allocate’ at third-party-buck/platform007/build/libgcc/include/c++/7.3.0/ext/new_allocator.h:111:0,
    inlined from ‘allocate’ at third-party-buck/platform007/build/libgcc/include/c++/7.3.0/bits/alloc_traits.h:436:0,
    inlined from ‘_M_allocate’ at third-party-buck/platform007/build/libgcc/include/c++/7.3.0/bits/stl_vector.h:172:0,
    inlined from ‘_M_default_append’ at third-party-buck/platform007/build/libgcc/include/c++/7.3.0/bits/vector.tcc:571:0,
    inlined from ‘resize’ at third-party-buck/platform007/build/libgcc/include/c++/7.3.0/bits/stl_vector.h:671:0,
    inlined from ‘THTensor_resizeDim’ at caffe2/aten/src/TH/THTensor.hpp:123:0,
    inlined from ‘THFloatTensor_squeeze1d.part.198’ at caffe2/aten/src/TH/generic/THTensor.cpp:429:0,
    inlined from ‘THFloatTensor_squeeze1d’:
  common/memory/OperatorOverride.cpp:86:23: error:
  argument 1 value ‘18446744073709551608’ exceeds maximum object size 9223372036854775807 [-Werror=alloc-size-larger-than=]
   void* ptr = malloc(size);

Reviewed By: soumith

Differential Revision: D9568621

fbshipit-source-id: 4569a4be897d669caa3f283f4b84ec829e8d77ad
  • Loading branch information
pixelb authored and facebook-github-bot committed Aug 30, 2018
1 parent 611a608 commit 23b0c90
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions aten/src/TH/generic/THTensor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ void THTensor_(select)(THTensor *self, THTensor *src, int dimension, int64_t sli
self->set_size(d, self->size(d+1));
self->set_stride(d, self->stride(d+1));
}
self->resize_dim(self->dim() - 1);
self->resize_dim((unsigned int)(self->dim() - 1));
}

void THTensor_(transpose)(THTensor *self, THTensor *src, int dimension1, int dimension2)
Expand Down Expand Up @@ -444,7 +444,7 @@ void THTensor_(squeeze1d)(THTensor *self, THTensor *src, int dimension)
self->set_size(d, self->size(d+1));
self->set_stride(d, self->stride(d+1));
}
self->resize_dim(self->dim() - 1);
self->resize_dim((unsigned int)(self->dim() - 1));
}
}

Expand Down
2 changes: 1 addition & 1 deletion aten/src/THC/THCTensor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ void THCTensor_squeeze1d(THCState *state, THCTensor *self, THCTensor *src, int d
self->set_size(d, self->size(d+1));
self->set_stride(d, self->stride(d+1));
}
self->resize_dim(self->dim() - 1);
self->resize_dim((unsigned int)(self->dim() - 1));
}
}

Expand Down
2 changes: 1 addition & 1 deletion aten/src/THC/generic/THCTensor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ void THCTensor_(select)(THCState *state, THCTensor *self, THCTensor *src, int di
self->set_size(d, self->size(d+1));
self->set_stride(d, self->stride(d+1));
}
self->resize_dim(self->dim() - 1);
self->resize_dim((unsigned int)(self->dim() - 1));
}

void THCTensor_(transpose)(THCState *state, THCTensor *self, THCTensor *src, int dimension1, int dimension2)
Expand Down

0 comments on commit 23b0c90

Please sign in to comment.