Skip to content

Instantly share code, notes, and snippets.

@matthauck
Created July 11, 2022 17:18
Show Gist options
  • Save matthauck/011a5b8bcdbd8fafb5440e46b7561703 to your computer and use it in GitHub Desktop.
Save matthauck/011a5b8bcdbd8fafb5440e46b7561703 to your computer and use it in GitHub Desktop.
absl data loss
// compile with: cl -I<absl-path> /EHsc /W3 main.cpp
#include "absl/container/btree_map.h"
int main( int argc, const char* argv[] )
{
absl::btree_map< int, int > map;
map[1] = 2;
return 0;
}
C:\code\include\absl/container/internal/btree.h(1725,59): error C2220: the following warning is treated as an error
C:\code\include\absl/container/internal/btree.h(2659): note: see reference to function template instantiation 'void absl::lts_20220623::container_internal::btree_node<Params>::emplace_value<const std::piecewise_construct_t&,_Ty,std::tuple<>>(const unsigned int,std::allocator<std::pair<const Key,Value>> *,const std::piecewise_construct_t &,_Ty &&,std::tuple<> &&)' being compiled
with
[
Params=absl::lts_20220623::container_internal::map_params<int,int,std::less<int>,std::allocator<std::pair<const int,int>>,256,false>,
_Ty=std::tuple<int &&>,
Key=int,
Value=int
]
C:\code\include\absl/container/internal/btree.h(2690): note: see reference to function template instantiation 'void absl::lts_20220623::container_internal::btree_node<Params>::emplace_value<const std::piecewise_construct_t&,_Ty,std::tuple<>>(const unsigned int,std::allocator<std::pair<const Key,Value>> *,const std::piecewise_construct_t &,_Ty &&,std::tuple<> &&)' being compiled
with
[
Params=absl::lts_20220623::container_internal::map_params<int,int,std::less<int>,std::allocator<std::pair<const int,int>>,256,false>,
_Ty=std::tuple<int &&>,
Key=int,
Value=int
]
C:\code\include\absl/container/internal/btree.h(2135): note: see reference to function template instantiation 'absl::lts_20220623::container_internal::btree_iterator<absl::lts_20220623::container_internal::btree_node<Params>,std::pair<const Key,Value> &,std::pair<const Key,Value> *> absl::lts_20220623::container_internal::btree<Params>::internal_emplace<const std::piecewise_construct_t&,_Ty,std::tuple<>>(absl::lts_20220623::container_internal::btree_iterator<absl::lts_20220623::container_internal::btree_node<Params>,std::pair<const Key,Value> &,std::pair<const Key,Value> *>,const std::piecewise_construct_t &,_Ty &&,std::tuple<> &&)' being compiled
with
[
Params=absl::lts_20220623::container_internal::map_params<int,int,std::less<int>,std::allocator<std::pair<const int,int>>,256,false>,
Key=int,
Value=int,
_Ty=std::tuple<int &&>
]
C:\code\include\absl/container/internal/btree.h(2155): note: see reference to function template instantiation 'absl::lts_20220623::container_internal::btree_iterator<absl::lts_20220623::container_internal::btree_node<Params>,std::pair<const Key,Value> &,std::pair<const Key,Value> *> absl::lts_20220623::container_internal::btree<Params>::internal_emplace<const std::piecewise_construct_t&,_Ty,std::tuple<>>(absl::lts_20220623::container_internal::btree_iterator<absl::lts_20220623::container_internal::btree_node<Params>,std::pair<const Key,Value> &,std::pair<const Key,Value> *>,const std::piecewise_construct_t &,_Ty &&,std::tuple<> &&)' being compiled
with
[
Params=absl::lts_20220623::container_internal::map_params<int,int,std::less<int>,std::allocator<std::pair<const int,int>>,256,false>,
Key=int,
Value=int,
_Ty=std::tuple<int &&>
]
C:\code\include\absl/container/internal/btree_container.h(525): note: see reference to function template instantiation 'std::pair<absl::lts_20220623::container_internal::btree_iterator<absl::lts_20220623::container_internal::btree_node<Params>,std::pair<const Key,Value> &,std::pair<const Key,Value> *>,bool> absl::lts_20220623::container_internal::btree<Params>::insert_unique<K,const std::piecewise_construct_t&,std::tuple<_Ty &&>,std::tuple<>>(const K &,const std::piecewise_construct_t &,std::tuple<_Ty &&> &&,std::tuple<> &&)' being compiled
with
[
Params=absl::lts_20220623::container_internal::map_params<int,int,std::less<int>,std::allocator<std::pair<const int,int>>,256,false>,
Key=int,
Value=int,
K=int,
_Ty=int
]
C:\code\include\absl/container/internal/btree_container.h(526): note: see reference to function template instantiation 'std::pair<absl::lts_20220623::container_internal::btree_iterator<absl::lts_20220623::container_internal::btree_node<Params>,std::pair<const Key,Value> &,std::pair<const Key,Value> *>,bool> absl::lts_20220623::container_internal::btree<Params>::insert_unique<K,const std::piecewise_construct_t&,std::tuple<_Ty &&>,std::tuple<>>(const K &,const std::piecewise_construct_t &,std::tuple<_Ty &&> &&,std::tuple<> &&)' being compiled
with
[
Params=absl::lts_20220623::container_internal::map_params<int,int,std::less<int>,std::allocator<std::pair<const int,int>>,256,false>,
Key=int,
Value=int,
K=int,
_Ty=int
]
C:\code\include\absl/container/internal/btree_container.h(467): note: see reference to function template instantiation 'std::pair<absl::lts_20220623::container_internal::btree_iterator<absl::lts_20220623::container_internal::btree_node<Params>,std::pair<const Key,Value> &,std::pair<const Key,Value> *>,bool> absl::lts_20220623::container_internal::btree_map_container<absl::lts_20220623::container_internal::btree<Params>>::try_emplace_impl<_Ty,>(K &&)' being compiled
with
[
Params=absl::lts_20220623::container_internal::map_params<int,int,std::less<int>,std::allocator<std::pair<const int,int>>,256,false>,
Key=int,
Value=int,
_Ty=int,
K=int
]
C:\code\include\absl/container/internal/btree_container.h(468): note: see reference to function template instantiation 'std::pair<absl::lts_20220623::container_internal::btree_iterator<absl::lts_20220623::container_internal::btree_node<Params>,std::pair<const Key,Value> &,std::pair<const Key,Value> *>,bool> absl::lts_20220623::container_internal::btree_map_container<absl::lts_20220623::container_internal::btree<Params>>::try_emplace_impl<_Ty,>(K &&)' being compiled
with
[
Params=absl::lts_20220623::container_internal::map_params<int,int,std::less<int>,std::allocator<std::pair<const int,int>>,256,false>,
Key=int,
Value=int,
_Ty=int,
K=int
]
C:\code\include\absl/container/internal/btree_container.h(487): note: see reference to function template instantiation 'std::pair<absl::lts_20220623::container_internal::btree_iterator<absl::lts_20220623::container_internal::btree_node<Params>,std::pair<const Key,Value> &,std::pair<const Key,Value> *>,bool> absl::lts_20220623::container_internal::btree_map_container<absl::lts_20220623::container_internal::btree<Params>>::try_emplace<int,,0>(int &&)' being compiled
with
[
Params=absl::lts_20220623::container_internal::map_params<int,int,std::less<int>,std::allocator<std::pair<const int,int>>,256,false>,
Key=int,
Value=int
]
C:\code\include\absl/container/internal/btree_container.h(487): note: see reference to function template instantiation 'std::pair<absl::lts_20220623::container_internal::btree_iterator<absl::lts_20220623::container_internal::btree_node<Params>,std::pair<const Key,Value> &,std::pair<const Key,Value> *>,bool> absl::lts_20220623::container_internal::btree_map_container<absl::lts_20220623::container_internal::btree<Params>>::try_emplace<int,,0>(int &&)' being compiled
with
[
Params=absl::lts_20220623::container_internal::map_params<int,int,std::less<int>,std::allocator<std::pair<const int,int>>,256,false>,
Key=int,
Value=int
]
C:\code\main.cpp(6): note: see reference to function template instantiation 'int &absl::lts_20220623::container_internal::btree_map_container<absl::lts_20220623::container_internal::btree<absl::lts_20220623::container_internal::map_params<Key,Value,Compare,Alloc,256,false>>>::operator []<int>(int &&)' being compiled
with
[
Key=int,
Value=int,
Compare=std::less<int>,
Alloc=std::allocator<std::pair<const int,int>>
]
C:\code\main.cpp(6): note: see reference to function template instantiation 'int &absl::lts_20220623::container_internal::btree_map_container<absl::lts_20220623::container_internal::btree<absl::lts_20220623::container_internal::map_params<Key,Value,Compare,Alloc,256,false>>>::operator []<int>(int &&)' being compiled
with
[
Key=int,
Value=int,
Compare=std::less<int>,
Alloc=std::allocator<std::pair<const int,int>>
]
C:\code\include\absl/container/internal/btree.h(1725,59): warning C4267: 'argument': conversion from 'size_t' to 'const unsigned char', possible loss of data
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment