gcc-5 compile error in 62.0.3202.18

172 views
Skip to first unread message

Paweł Hajdan, Jr.

unread,
Sep 28, 2017, 12:48:05 PM9/28/17
to chromium-dev
M62 introduced some change that I'm not sure how to make compile with gcc-5. Does anyone have ideas how to make gcc-5.4.0 compile this code?

In file included from ../../gpu/ipc/common/mailbox_holder_struct_traits.h:10:0,
                 from ../../cc/ipc/texture_mailbox_struct_traits.h:10,
                 from ../../cc/ipc/copy_output_result_struct_traits.h:10,
                 from ../../cc/ipc/copy_output_result_struct_traits.cc:5:
../../gpu/ipc/common/mailbox_struct_traits.h: In static member function ‘static base::span<const signed char> mojo::StructTraits<gpu::mojom::MailboxDataView, gpu::Mailbox>::name(const gpu::Mailbox&)’:
../../gpu/ipc/common/mailbox_struct_traits.h:18:20: error: could not convert ‘(const int8_t*)(& mailbox.gpu::Mailbox::name)’ from ‘const int8_t* {aka const signed char*}’ to ‘base::span<const signed char>’
     return mailbox.name;
                    ^

Paweł

Ken Rockot

unread,
Sep 28, 2017, 12:58:16 PM9/28/17
to Paweł Hajdan, Jr., chromium-dev
Looks like an issue with base::span template magic. +dcheng who I believe changed this and introduced base::span.

The gist is that mailbox.name is an int8_t[] and gcc is probably failing to resolve the correct span constructor (the one templated over a constant array size). A workaround should be:

  return base::span<const int8_t>(&mailbox.name[0], GL_MAILBOX_SIZE_CHROMIUM);

--
--
Chromium Developers mailing list: chromi...@chromium.org
View archives, change email options, or unsubscribe:
http://groups.google.com/a/chromium.org/group/chromium-dev
---
You received this message because you are subscribed to the Google Groups "Chromium-dev" group.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/chromium-dev/CAATLsPbmfm9vbn3tmCvvYzkG1SF3N1XgXeWMS_ai1DPkPye%2Bug%40mail.gmail.com.

Paweł Hajdan, Jr.

unread,
Sep 28, 2017, 3:01:52 PM9/28/17
to Ken Rockot, Daniel Cheng, chromium-dev
Ah, thanks!

I came up with the following diff. Does it look OK? I probably wouldn't upstream that, but distros using older gcc could carry this as local patch. I'd still want to confirm its sanity and correctness with you.

--- a/gpu/ipc/common/mailbox_struct_traits.h
+++ b/gpu/ipc/common/mailbox_struct_traits.h
@@ -15,7 +15,7 @@ namespace mojo {
 template <>
 struct StructTraits<gpu::mojom::MailboxDataView, gpu::Mailbox> {
   static base::span<const int8_t> name(const gpu::Mailbox& mailbox) {
-    return mailbox.name;
+    return base::span<const int8_t>(&mailbox.name[0], GL_MAILBOX_SIZE_CHROMIUM);
   }
   static bool Read(gpu::mojom::MailboxDataView data, gpu::Mailbox* out);
 };
--- a/services/viz/public/cpp/compositing/filter_operation_struct_traits.h
+++ b/services/viz/public/cpp/compositing/filter_operation_struct_traits.h
@@ -134,7 +134,7 @@ struct StructTraits<viz::mojom::FilterOperationDataView, cc::FilterOperation> {
   static base::span<const float> matrix(const cc::FilterOperation& operation) {
     if (operation.type() != cc::FilterOperation::COLOR_MATRIX)
       return base::span<const float>();
-    return operation.matrix();
+    return base::span<const float>(operation.matrix());
   }

   static base::span<const gfx::Rect> shape(
--- a/services/viz/public/cpp/compositing/quads_struct_traits.h
+++ b/services/viz/public/cpp/compositing/quads_struct_traits.h
@@ -303,7 +303,7 @@ struct StructTraits<viz::mojom::TextureQuadStateDataView, viz::DrawQuad> {
   static base::span<const float> vertex_opacity(const viz::DrawQuad& input) {
     const viz::TextureDrawQuad* quad =
         viz::TextureDrawQuad::MaterialCast(&input);
-    return quad->vertex_opacity;
+    return base::span<const float>(quad->vertex_opacity);
   }

   static bool y_flipped(const viz::DrawQuad& input) {
--- a/third_party/WebKit/Source/platform/exported/WebCORS.cpp
+++ b/third_party/WebKit/Source/platform/exported/WebCORS.cpp
@@ -480,7 +480,7 @@ WebString AccessControlErrorString(
     }
     default:
       NOTREACHED();
-      return "";
+      return WebString();
   }
 }

@@ -512,7 +512,7 @@ WebString PreflightErrorString(const PreflightStatus status,
     }
     default:
       NOTREACHED();
-      return "";
+      return WebString();
   }
 }

@@ -533,7 +533,7 @@ WebString RedirectErrorString(const RedirectStatus status,
     }
     default:
       NOTREACHED();
-      return "";
+      return WebString();
   }
 }

Paweł

Ken Rockot

unread,
Sep 28, 2017, 3:05:30 PM9/28/17
to Paweł Hajdan, Jr., Daniel Cheng, chromium-dev
Looks OK but given the other two base::span changes it kind of looks explicit construction should also work for Mailbox, i.e.:

  return base::span<const int8_t>(mailbox.name);

Is that not the case?

Marijn Kruisselbrink

unread,
Sep 28, 2017, 3:08:49 PM9/28/17
to Ken Rockot, Paweł Hajdan, Jr., Daniel Cheng, chromium-dev
On Thu, Sep 28, 2017 at 12:04 PM, Ken Rockot <roc...@chromium.org> wrote:
Looks OK but given the other two base::span changes it kind of looks explicit construction should also work for Mailbox, i.e.:

  return base::span<const int8_t>(mailbox.name);
Or maybe even base::make_span(mailbox.name), avoiding the explicit type entirely?

 

Paweł Hajdan, Jr.

unread,
Oct 3, 2017, 7:08:11 AM10/3/17
to Marijn Kruisselbrink, Ken Rockot, Daniel Cheng, chromium-dev
Yup, that works.

Thanks!

Paweł

Daniel Cheng

unread,
Oct 3, 2017, 1:17:57 PM10/3/17
to Paweł Hajdan, Jr., Marijn Kruisselbrink, Ken Rockot, chromium-dev
Oops, sorry for missing this thread--I was travelling. Pawel, changing it to use base::make_span looks fine. I think it's a defect in gcc5 and how it looks up conversion constructors, but I wasn't able to find a bug number (and it seems to be fixed for gcc6 anyway).

Daniel
Reply all
Reply to author
Forward
0 new messages