You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@arrow.apache.org by we...@apache.org on 2019/02/26 06:29:15 UTC

[arrow] branch master updated: ARROW-4641: [C++][Flight] Suppress strict aliasing warnings from "unsafe" casts in client.cc

This is an automated email from the ASF dual-hosted git repository.

wesm pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/arrow.git


The following commit(s) were added to refs/heads/master by this push:
     new 49f1ff5  ARROW-4641: [C++][Flight] Suppress strict aliasing warnings from "unsafe" casts in client.cc
49f1ff5 is described below

commit 49f1ff521b6e1b05ff85aac7b5a97161cf589cdf
Author: Wes McKinney <we...@apache.org>
AuthorDate: Tue Feb 26 00:29:06 2019 -0600

    ARROW-4641: [C++][Flight] Suppress strict aliasing warnings from "unsafe" casts in client.cc
    
    The type-casting trick we are using to sneak a different kind of object into `SerializationTraits<pb::FlightData>` looks like a `-Wstrict-aliasing` violation (which it would be, if any code tried to use the reference as the protobuf type)
    
    Author: Wes McKinney <we...@apache.org>
    
    Closes #3719 from wesm/ARROW-4641 and squashes the following commits:
    
    b7bded1f <Wes McKinney> Suppress -Wstrict-aliasing locally
    45929ab3 <Wes McKinney> Do not warn about strict aliasing violations in Flight serialization paths
---
 cpp/src/arrow/flight/client.cc | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/cpp/src/arrow/flight/client.cc b/cpp/src/arrow/flight/client.cc
index 2563126..50c70ee 100644
--- a/cpp/src/arrow/flight/client.cc
+++ b/cpp/src/arrow/flight/client.cc
@@ -123,8 +123,15 @@ class FlightPutWriter::FlightPutWriterImpl : public ipc::RecordBatchWriter {
     RETURN_NOT_OK(
         ipc::internal::GetRecordBatchPayload(batch, pool_, &payload.ipc_message));
 
+#ifndef _WIN32
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wstrict-aliasing"
+#endif
     if (!writer_->Write(*reinterpret_cast<const pb::FlightData*>(&payload),
                         grpc::WriteOptions())) {
+#ifndef _WIN32
+#pragma GCC diagnostic pop
+#endif
       std::stringstream ss;
       ss << "Could not write record batch to stream: "
          << rpc_->context.debug_error_string();
@@ -307,8 +314,15 @@ class FlightClient::FlightClientImpl {
     pb_descr.SerializeToString(&str_descr);
     RETURN_NOT_OK(Buffer::FromString(str_descr, &payload.descriptor));
 
+#ifndef _WIN32
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wstrict-aliasing"
+#endif
     if (!write_stream->Write(*reinterpret_cast<const pb::FlightData*>(&payload),
                              grpc::WriteOptions())) {
+#ifndef _WIN32
+#pragma GCC diagnostic pop
+#endif
       std::stringstream ss;
       ss << "Could not write descriptor and schema to stream: "
          << rpc->context.debug_error_string();