Project

General

Profile

Bug #1150

Specialize pup for std::vector to vector<bool>

Added by Phil Miller almost 3 years ago. Updated almost 3 years ago.

Status:
Merged
Priority:
Normal
Assignee:
Category:
Migration
Target version:
Start date:
08/01/2016
Due date:
% Done:

0%


Description

I get a compiler warning "taking address of temporary" when I pup a std::vector<bool>. There is no warning when I pup std::vector<int>. I am using charm version 6.6.1 and gcc. I haven't gotten a chance to test it on the latest version of charm, but there is a simple minimal case that produces the warning so I thought I would pass it along quickly.

Compile this code:


#include <charm++.h>

void my_pup(PUP::er &p)
{
std::vector<int>  justFine;
std::vector<bool> troubleMaker;

p | justFine;
p | troubleMaker;
}

Get this warning:

In file included from /opt/build/charm/bin/../include/sdag.h:27,
from /opt/build/charm/bin/../include/CkMarshall.decl.h:6,
from /opt/build/charm/bin/../include/charm++.h:134,
from deleteme.cpp:1:
/opt/build/charm/bin/../include/pup_stl.h: In function ‘void PUP::PUP_stl_container_items(PUP::er&, container&) [with container = std::vector<bool, std::allocator<bool> >, dtype = bool]’:
/opt/build/charm/bin/../include/pup_stl.h:156:   instantiated from ‘void PUP::PUP_stl_container(PUP::er&, container&) [with container = std::vector<bool, std::allocator<bool> >, dtype = bool]’
/opt/build/charm/bin/../include/pup_stl.h:179:   instantiated from ‘void PUP::operator|(PUP::er&, std::vector<T, std::allocator<_Tp1> >&) [with T = bool]’
deleteme.cpp:9:   instantiated from here
/opt/build/charm/bin/../include/pup_stl.h:138: warning: taking address of temporary

Note that std::vector<bool> does not act like the generic std::vector<T>: https://isocpp.org/blog/2012/11/on-vectorbool

Please implement an explicit specialization for std::vector<bool> in pup_stl.h so that the warning does not occur.

History

#1 Updated by Sam White almost 3 years ago

  • Category set to Migration
  • Status changed from New to Implemented

#2 Updated by Phil Miller almost 3 years ago

  • Status changed from Implemented to Merged
  • translation missing: en.field_closed_date set to 2016-08-23 15:06:26.286815

#3 Updated by Phil Miller almost 3 years ago

  • Target version changed from 6.8.0 to 6.8.0-beta1

Also available in: Atom PDF