Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(3441)

Issue 22840043: code review 22840043: cmd/cgo: fix handling of array of pointers when using clang (Closed)

Can't Edit
Can't Publish+Mail
Start Review
Created:
10 years, 5 months ago by rsc
Modified:
10 years, 5 months ago
Reviewers:
iant
CC:
golang-dev, iant
Visibility:
Public.

Description

cmd/cgo: fix handling of array of pointers when using clang Clang does not record the "size" field for pointer types, so we must insert the size ourselves. We were already doing this, but only for the case of pointer types. For an array of pointer types, the setting of the size for the nested pointer type was happening after the computation of the size of the array type, meaning that the array type was always computed as 0 bytes. Delay the size computation. This bug happens on all Clang systems, not just FreeBSD. Our test checked that cgo wrote something, not that it was correct. FreeBSD's default clang rejects array[0] as a C struct field, so it noticed the incorrect sizes. But the sizes were incorrect everywhere. Update testcdefs to check the output has the right semantics. Fixes issue 6292.

Patch Set 1 #

Patch Set 2 : diff -r 8b49cdda6ff4 https://code.google.com/p/go/ #

Patch Set 3 : diff -r 8b49cdda6ff4 https://code.google.com/p/go/ #

Total comments: 2

Patch Set 4 : diff -r 77e77f508509 https://code.google.com/p/go/ #

Unified diffs Side-by-side diffs Delta from patch set Stats (+80 lines, -15 lines) Patch
A misc/cgo/testcdefs/main.c View 1 2 3 1 chunk +48 lines, -0 lines 0 comments Download
M misc/cgo/testcdefs/main.go View 1 1 chunk +8 lines, -3 lines 0 comments Download
M misc/cgo/testcdefs/test.bash View 1 1 chunk +1 line, -1 line 0 comments Download
M src/cmd/cgo/gcc.go View 1 2 3 3 chunks +23 lines, -11 lines 0 comments Download

Messages

Total messages: 4
rsc
Hello golang-dev@googlegroups.com, I'd like you to review this change to https://code.google.com/p/go/
10 years, 5 months ago (2013-11-07 15:48:30 UTC) #1
iant
LGTM https://codereview.appspot.com/22840043/diff/40001/misc/cgo/testcdefs/main.c File misc/cgo/testcdefs/main.c (right): https://codereview.appspot.com/22840043/diff/40001/misc/cgo/testcdefs/main.c#newcode47 misc/cgo/testcdefs/main.c:47: USED(&ret); // flush return value s/USED/FLUSH/
10 years, 5 months ago (2013-11-07 18:36:59 UTC) #2
rsc
https://codereview.appspot.com/22840043/diff/40001/misc/cgo/testcdefs/main.c File misc/cgo/testcdefs/main.c (right): https://codereview.appspot.com/22840043/diff/40001/misc/cgo/testcdefs/main.c#newcode47 misc/cgo/testcdefs/main.c:47: USED(&ret); // flush return value On 2013/11/07 18:36:59, iant ...
10 years, 5 months ago (2013-11-07 18:38:53 UTC) #3
rsc
10 years, 5 months ago (2013-11-07 20:24:56 UTC) #4
*** Submitted as https://code.google.com/p/go/source/detail?r=e6794866ebeb ***

cmd/cgo: fix handling of array of pointers when using clang

Clang does not record the "size" field for pointer types,
so we must insert the size ourselves. We were already
doing this, but only for the case of pointer types.
For an array of pointer types, the setting of the size for
the nested pointer type was happening after the computation
of the size of the array type, meaning that the array type
was always computed as 0 bytes. Delay the size computation.

This bug happens on all Clang systems, not just FreeBSD.
Our test checked that cgo wrote something, not that it was correct.
FreeBSD's default clang rejects array[0] as a C struct field,
so it noticed the incorrect sizes. But the sizes were incorrect
everywhere.

Update testcdefs to check the output has the right semantics.

Fixes issue 6292.

R=golang-dev, iant
CC=golang-dev
https://codereview.appspot.com/22840043
Sign in to reply to this message.

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b