Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

std::move of zmq::message_t not behaving as expected

Aperta
#644 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
35/100
Tipo di issue
Bug
Chiarezza
Da chiarire
Stato di attività
Ferma
Stack tecnologico
cpp

Direzione di ricerca

Start with the supplied ZMQTests.BUG reproducer and inspect the move-assignment paths for zmq::message_t and multipart_t::pop. Compare the two scopes' object lifetimes and ownership, then add or update a regression test so the intended zero-copy view behavior is explicit and the test passes.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

I'm trying to pin a message_t in a way I can use it later for zero copy and I'm having a bear of a time doing it. In the below test the first one passes and the second one fails. I would have expected them both to pass since the underlying data isn't being memcpy'd anywhere. I can go with the first message, but its a bit unexpected to me that the first one fails.

TEST(ZMQTests, BUG)
{
  {
    zmq::multipart_t test;
    test.pushstr("echo2");

    zmq::multipart_t message;
    std::string_view view;

    zmq::message_t foo = test.pop();
    view = {static_cast<char*>(foo.data()), foo.size()};
    message = std::move(foo);

    EXPECT_EQ(std::string("echo2"), view);
  }
  {
    zmq::multipart_t test;
    test.pushstr("echo2");

    zmq::message_t message;
    std::string_view view;

    zmq::message_t foo = test.pop();
    view = {static_cast<char*>(foo.data()), foo.size()};
    message = std::move(foo);

    EXPECT_EQ(std::string("echo2"), view);
  }
}
Lingua principale
C++
Stelle
2.3k
Fork
799
Merge medio
2g 17h
PR unite (30g)
1

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di zeromq/cppzmq

Tutte le issue di zeromq/cppzmq

Issue simili

Altre issue su C++

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.