[ 
https://issues.apache.org/jira/browse/ARROW-12240?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17316841#comment-17316841
 ] 

Yibo Cai edited comment on ARROW-12240 at 4/8/21, 4:40 AM:
-----------------------------------------------------------

This warning only happens with clang-12. The reason is that unordered_map is 
[standard layout 
type|https://en.cppreference.com/w/cpp/named_req/StandardLayoutType] before 
clang-12, but may change to non-standard-layout in later version: 
https://godbolt.org/z/ejEoYf5oq

[ConvertOptions|https://github.com/apache/arrow/blob/a691e03ce3b5b9b24eccfe600d006ff6a05be84e/cpp/src/arrow/csv/options.h#L64]
 struct has stl container data members (vector, unordered_map, string). These 
containers happen to be standard-layout for current clang version. Looks 
there's no spec to guarantee they must be implemented as standard-layout-type. 
So the ConvertOptions struct may becomes non-standard-layout for later compiler 
versions and cause trouble.

Not quite familiar with cython, will like to seek comments. cc [~apitrou] 
[~bkietz]
Trick in https://github.com/apache/arrow/pull/9274 should fix this issue.
But use offsetof macro to exact struct member offset looks a big limit to 
struct type. I don't know under which condition will cython generate this code.


was (Author: yibocai):
This warning only happens with clang-12. The reason is that unordered_map is 
[standard layout 
type|https://en.cppreference.com/w/cpp/named_req/StandardLayoutType] before 
clang-12, but may change to non-standard-layout in later version: 
https://godbolt.org/z/ejEoYf5oq

[ConvertOptions|https://github.com/apache/arrow/blob/a691e03ce3b5b9b24eccfe600d006ff6a05be84e/cpp/src/arrow/csv/options.h#L64]
 struct has stl container data members (vector, unordered_map, string). These 
containers happen to be standard-layout for current clang version. Looks 
there's no spec to guarantee they must be implemented as standard-layout-type. 
So the ConvertOptions struct may becomes non-standard-layout for later compiler 
versions and cause trouble.

Not quite familiar with cython, will like to seek comments. cc [~apitrou] 
[~bkietz]

> [Python] invalid-offsetof warning from apple clang-12
> -----------------------------------------------------
>
>                 Key: ARROW-12240
>                 URL: https://issues.apache.org/jira/browse/ARROW-12240
>             Project: Apache Arrow
>          Issue Type: Bug
>          Components: Python
>            Reporter: Yibo Cai
>            Assignee: Yibo Cai
>            Priority: Major
>
> Similar issue as https://issues.apache.org/jira/browse/ARROW-11299.
> Found when building pyarrow on Macos M1. I don't think it's platform related.
> No warning for clang-9,  but apple clang-12 complains about it.
> Error log:
> {code:bash}
> [ 13%] Building CXX object CMakeFiles/_csv.dir/_csv.cpp.o
> /Users/cyb/work/arrow/python/build/temp.macosx-11.0-arm64-3.9/_csv.cpp:19051:133:
>  warning: offset of on non-standard-layout type 'struct 
> __pyx_obj_7pyarrow_4_csv_ConvertOptions' [-Winvalid-offsetof]
>   if (__pyx_type_7pyarrow_4_csv_ConvertOptions.tp_weaklistoffset == 0) 
> __pyx_type_7pyarrow_4_csv_ConvertOptions.tp_weaklistoffset = offsetof(struct 
> __pyx_obj_7pyarrow_4_csv_ConvertOptions, __pyx_base.__weakref__);
> ^                                                        ~~~~~~~~~~
> /Library/Developer/CommandLineTools/usr/lib/clang/12.0.0/include/stddef.h:104:24:
>  note: expanded from macro 'offsetof'
> #define offsetof(t, d) __builtin_offsetof(t, d)
> {code}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to