You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Several interfaces of the CouplingAdapter such as announceQuantity and getQuantityVector use the new precice::string_view after the port to precice:develop / preCICEv3. One can pass also std::strings or "string"-literals, which are then converted. As literals such as "dataName" are \0-terminated char[], their size is 1 greater than the string and they produce a different string_view.
std::string("dataName") seems to be compatible with precice::string_view("dataName", 8) while "dataName" produces precice::string_view("dataName", 9).
This currently allows to announce the same quantity twice, since the adapter checks whether the string_view has already been announced (false) and preCICE seems to view them both as equal to the name registered in the preCICE config file.
You noticed an implementation detail of using the precice::span-based precice::string_views in the API.
While you are correct about the literals containing the NULL byte, preCICE handles this internally.
In src/precice/Participant.cpp, we convert all precice::string_views to std::string_view before passing them ParticipantImpl.
This step removes the NULL byte and everything past it from given string_views.
Description
Several interfaces of the
CouplingAdapter
such asannounceQuantity
andgetQuantityVector
use the newprecice::string_view
after the port toprecice:develop
/ preCICEv3. One can pass alsostd::string
s or "string"-literals, which are then converted. As literals such as"dataName"
are\0
-terminatedchar[]
, their size is 1 greater than the string and they produce a differentstring_view
.std::string("dataName")
seems to be compatible withprecice::string_view("dataName", 8)
while"dataName"
producesprecice::string_view("dataName", 9)
.This currently allows to announce the same quantity twice, since the adapter checks whether the
string_view
has already been announced (false) and preCICE seems to view them both as equal to the name registered in the preCICE config file.Environment
Ubuntu 22.04 LTS, preCICE:develop, DuMuX 3.8, DuMuX-preCICE:develop
Steps to reproduce
Announce a quantity twice, using once a
std::string
and once a literalExpected behavior
If passing a
std::string
and literal are allowed, they should refer to the same quantity.Actual behavior
Depending on how the string_view is created, the quantities are treated as distinct.
The text was updated successfully, but these errors were encountered: