https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90224
Bug ID: 90224 Summary: Resource leak.. Product: gcc Version: 6.4.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: libstdc++ Assignee: unassigned at gcc dot gnu.org Reporter: venkateshprabu at gmail dot com Target Milestone: --- File: /aarch64-gnu-linux/usr/include/c++/6.4.1/bits/unordered_set.h operator = Resource leak The system resource will not be reclaimed and reused, reducing the future availability of the resource. In std::unordered_set<communication::remoteUI::ResourceID::type, std::hash<communication::remoteUI::ResourceID::type>, std::equal_to<communication::remoteUI::ResourceID::type>, std::allocator<communication::remoteUI::ResourceID::type>>::operator =(std::unordered_set<communication::remoteUI::ResourceID::type, std::hash<communication::remoteUI::ResourceID::type>, std::equal_to<communication::remoteUI::ResourceID::type>, std::allocator<communication::remoteUI::ResourceID::type>> const&): Leak of memory or pointers to system resources (CWE-404) Is this false positive by coverity ? Coverity report: 242 unordered_set(initializer_list<value_type> __l, 243 size_type __n, 244 const allocator_type& __a) 245 : unordered_set(__l, __n, hasher(), key_equal(), __a) 246 { } 247 248 unordered_set(initializer_list<value_type> __l, 249 size_type __n, const hasher& __hf, 250 const allocator_type& __a) 251 : unordered_set(__l, __n, __hf, key_equal(), __a) 252 { } 253 254 /// Copy assignment operator. 255 unordered_set& 1. alloc_arg: operator = allocates memory that is stored into this->_M_h._M_buckets. [show details] CID 8652455 (#1 of 1): Resource leak (RESOURCE_LEAK) 2. overwrite_var: Overwriting this->_M_h._M_buckets in call to operator = leaks the storage that this->_M_h._M_buckets points to. [show details] 256 operator=(const unordered_set&) = default; 257 258 /// Move assignment operator. 259 unordered_set& 260 operator=(unordered_set&&) = default; 261 262 /** 263 * @brief %Unordered_set list assignment operator. 264 * @param __l An initializer_list. 265 * 266 * This function fills an %unordered_set with copies of the elements in 267 * the initializer list @a __l. 268 * 269 * Note that the assignment completely changes the %unordered_set and 270 * that the resulting %unordered_set's size is the same as the number 271 * of elements assigned. Old data may be lost. 272 */ 273 unordered_set& 274 operator=(initializer_list<value_type> __l) 275 { 276 _M_h = __l; 277 return *this; 278 } 279 280 /// Returns the allocator object with which the %unordered_set was 281 /// constructed. 282 allocator_type 283 get_allocator() const noexcept 284 { return _M_h.get_allocator(); } 285 286 // size and capacity: 287 288 /// Returns true if the %unordered_set is empty. 289 bool 290 empty() const noexcept