upb icon indicating copy to clipboard operation
upb copied to clipboard

Alignment and qualifier warnings in `UPB_PTR_AT`

Open lorenz opened this issue 3 years ago • 1 comments

When building upb-compiled headers with LLVM 14 (running on Linux, building for Windows x64) I get tons of these warnings:

In file included from bazel-out/x64_windows-opt/bin/external/envoy_api/envoy/extensions/load_balancing_policies/ring_hash/v3/ring_hash.upb.c:14:
bazel-out/x64_windows-opt/bin/external/com_envoyproxy_protoc_gen_validate/validate/validate.upb.h(694,4): warning: cast from 'const struct validate_FloatRules *' to 'char *' drops const qualifier [-Wcast-qual]
  *UPB_PTR_AT(msg, UPB_SIZE(12, 12), float) = 0;
   ^
external/upb/upb/port_def.inc(69,52): note: expanded from macro 'UPB_PTR_AT'
#define UPB_PTR_AT(msg, ofs, type) ((type*)((char*)(msg) + (ofs)))
                                                   ^
In file included from bazel-out/x64_windows-opt/bin/external/envoy_api/envoy/extensions/load_balancing_policies/ring_hash/v3/ring_hash.upb.c:14:
bazel-out/x64_windows-opt/bin/external/com_envoyproxy_protoc_gen_validate/validate/validate.upb.h(694,4): warning: cast from 'char *' to 'float *' increases required alignment from 1 to 4 [-Wcast-align]
  *UPB_PTR_AT(msg, UPB_SIZE(12, 12), float) = 0;
   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
external/upb/upb/port_def.inc(69,37): note: expanded from macro 'UPB_PTR_AT'
#define UPB_PTR_AT(msg, ofs, type) ((type*)((char*)(msg) + (ofs)))
                                    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Is this a problem with the toolchain or is this expected and I should just disable these? Or an actual bug?

lorenz avatar Aug 02 '22 17:08 lorenz

Almost certainly just an annoyance instead of an actual bug. I will look into cleaning up these warnings.

ericsalo avatar Aug 02 '22 18:08 ericsalo