Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build warnings of [-Wsingle-bit-bitfield-constant-conversion] from outdated GraphViz library #80

Closed
thomasfleming-cs opened this issue Jan 4, 2024 · 1 comment · Fixed by #85

Comments

@thomasfleming-cs
Copy link

Environment details

Go version

$ go version
go version go1.21.1 darwin/arm64

C Compiler

$ go env
...
CC='clang'
...

$ clang --version
Apple clang version 15.0.0 (clang-1500.1.0.2.5)
Target: arm64-apple-darwin23.2.0
Thread model: posix
...

Issue

When building the example code in the repository's readme with go build, I see the following compiler warnings from clang:

# github.com/goccy/go-graphviz/internal/ccall
In file included from common.c:5:
../../../../go/modcache/github.com/goccy/go-graphviz@v0.1.2/internal/ccall/common/emit.c:165:35: warning: implicit truncation from 'int' to a one-bit wide bit-field changes value from 1 to -1 [-Wsingle-bit-bitfield-constant-conversion]
../../../../go/modcache/github.com/goccy/go-graphviz@v0.1.2/internal/ccall/common/emit.c:2540:24: warning: implicit truncation from 'int' to a one-bit wide bit-field changes value from 1 to -1 [-Wsingle-bit-bitfield-constant-conversion]
../../../../go/modcache/github.com/goccy/go-graphviz@v0.1.2/internal/ccall/common/emit.c:2596:35: warning: implicit truncation from 'int' to a one-bit wide bit-field changes value from 1 to -1 [-Wsingle-bit-bitfield-constant-conversion]
../../../../go/modcache/github.com/goccy/go-graphviz@v0.1.2/internal/ccall/common/emit.c:2602:35: warning: implicit truncation from 'int' to a one-bit wide bit-field changes value from 1 to -1 [-Wsingle-bit-bitfield-constant-conversion]
../../../../go/modcache/github.com/goccy/go-graphviz@v0.1.2/internal/ccall/common/emit.c:2612:31: warning: implicit truncation from 'int' to a one-bit wide bit-field changes value from 1 to -1 [-Wsingle-bit-bitfield-constant-conversion]
../../../../go/modcache/github.com/goccy/go-graphviz@v0.1.2/internal/ccall/common/emit.c:2623:31: warning: implicit truncation from 'int' to a one-bit wide bit-field changes value from 1 to -1 [-Wsingle-bit-bitfield-constant-conversion]
../../../../go/modcache/github.com/goccy/go-graphviz@v0.1.2/internal/ccall/common/emit.c:2628:31: warning: implicit truncation from 'int' to a one-bit wide bit-field changes value from 1 to -1 [-Wsingle-bit-bitfield-constant-conversion]
../../../../go/modcache/github.com/goccy/go-graphviz@v0.1.2/internal/ccall/common/emit.c:2641:28: warning: implicit truncation from 'int' to a one-bit wide bit-field changes value from 1 to -1 [-Wsingle-bit-bitfield-constant-conversion]
../../../../go/modcache/github.com/goccy/go-graphviz@v0.1.2/internal/ccall/common/emit.c:2650:33: warning: implicit truncation from 'int' to a one-bit wide bit-field changes value from 1 to -1 [-Wsingle-bit-bitfield-constant-conversion]
../../../../go/modcache/github.com/goccy/go-graphviz@v0.1.2/internal/ccall/common/emit.c:2659:32: warning: implicit truncation from 'int' to a one-bit wide bit-field changes value from 1 to -1 [-Wsingle-bit-bitfield-constant-conversion]
../../../../go/modcache/github.com/goccy/go-graphviz@v0.1.2/internal/ccall/common/emit.c:2668:32: warning: implicit truncation from 'int' to a one-bit wide bit-field changes value from 1 to -1 [-Wsingle-bit-bitfield-constant-conversion]

Note that this is a separate issue from #72 and is not fixed by #77.

These come from the bundled GraphViz library assigning a literal 1 to signed int bitfields of an obj_state_t. This issue was resolved in GraphViz 3.0.0 released on 2022-02-26. The specific commit with the fix is 96f9d101, which simply changes the relevant bitfields to unsigned ints. These bitfields are present in go-graphviz here:

int explicit_tooltip:1;
int explicit_tailtooltip:1;
int explicit_headtooltip:1;
int explicit_labeltooltip:1;
int explicit_tailtarget:1;
int explicit_headtarget:1;
int explicit_edgetarget:1;
int explicit_tailurl:1;
int explicit_headurl:1;
int labeledgealigned:1;

This issue can be resolved extremely easily by replacing the int keyword with unsigned (alias for unsigned int) in the above code, just as the GraphViz developers did. However, I would like to push for #42 to be finished and the bundled libraries (including GraphViz and Expat) to be updated to more recent versions. Updating the bundled dependencies would close out several other issues in this repository, like #47. More pressingly, bundling outdated libraries poses a security risk, as evidenced by the Expat CVEs mentioned in #76.

Please let me know if you would like me to submit a PR for the specific issue of the bitfield warnings. In the meantime, can you provide a timeline on when the bundled libraries might be able to be updated? Thank you.

@gedw99
Copy link

gedw99 commented May 27, 2024

I am also having the same bug on latest master and latest tagged.

clang --version
Apple clang version 15.0.0 (clang-1500.3.9.4)
Target: arm64-apple-darwin23.5.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin


go install github.com/goccy/go-graphviz/cmd/dot@master
go: downloading github.com/goccy/go-graphviz v0.1.3-0.20240305010347-606fdf55b06d
# github.com/goccy/go-graphviz/internal/ccall
In file included from common.c:5:
../../../pkg/mod/github.com/goccy/go-graphviz@v0.1.3-0.20240305010347-606fdf55b06d/internal/ccall/common/emit.c:165:35: warning: implicit truncation from 'int' to a one-bit wide bit-field changes value from 1 to -1 [-Wsingle-bit-bitfield-constant-conversion]
../../../pkg/mod/github.com/goccy/go-graphviz@v0.1.3-0.20240305010347-606fdf55b06d/internal/ccall/common/emit.c:2540:24: warning: implicit truncation from 'int' to a one-bit wide bit-field changes value from 1 to -1 [-Wsingle-bit-bitfield-constant-conversion]
../../../pkg/mod/github.com/goccy/go-graphviz@v0.1.3-0.20240305010347-606fdf55b06d/internal/ccall/common/emit.c:2596:35: warning: implicit truncation from 'int' to a one-bit wide bit-field changes value from 1 to -1 [-Wsingle-bit-bitfield-constant-conversion]
../../../pkg/mod/github.com/goccy/go-graphviz@v0.1.3-0.20240305010347-606fdf55b06d/internal/ccall/common/emit.c:2602:35: warning: implicit truncation from 'int' to a one-bit wide bit-field changes value from 1 to -1 [-Wsingle-bit-bitfield-constant-conversion]
../../../pkg/mod/github.com/goccy/go-graphviz@v0.1.3-0.20240305010347-606fdf55b06d/internal/ccall/common/emit.c:2612:31: warning: implicit truncation from 'int' to a one-bit wide bit-field changes value from 1 to -1 [-Wsingle-bit-bitfield-constant-conversion]
../../../pkg/mod/github.com/goccy/go-graphviz@v0.1.3-0.20240305010347-606fdf55b06d/internal/ccall/common/emit.c:2623:31: warning: implicit truncation from 'int' to a one-bit wide bit-field changes value from 1 to -1 [-Wsingle-bit-bitfield-constant-conversion]
../../../pkg/mod/github.com/goccy/go-graphviz@v0.1.3-0.20240305010347-606fdf55b06d/internal/ccall/common/emit.c:2628:31: warning: implicit truncation from 'int' to a one-bit wide bit-field changes value from 1 to -1 [-Wsingle-bit-bitfield-constant-conversion]
../../../pkg/mod/github.com/goccy/go-graphviz@v0.1.3-0.20240305010347-606fdf55b06d/internal/ccall/common/emit.c:2641:28: warning: implicit truncation from 'int' to a one-bit wide bit-field changes value from 1 to -1 [-Wsingle-bit-bitfield-constant-conversion]
../../../pkg/mod/github.com/goccy/go-graphviz@v0.1.3-0.20240305010347-606fdf55b06d/internal/ccall/common/emit.c:2650:33: warning: implicit truncation from 'int' to a one-bit wide bit-field changes value from 1 to -1 [-Wsingle-bit-bitfield-constant-conversion]
../../../pkg/mod/github.com/goccy/go-graphviz@v0.1.3-0.20240305010347-606fdf55b06d/internal/ccall/common/emit.c:2659:32: warning: implicit truncation from 'int' to a one-bit wide bit-field changes value from 1 to -1 [-Wsingle-bit-bitfield-constant-conversion]
../../../pkg/mod/github.com/goccy/go-graphviz@v0.1.3-0.20240305010347-606fdf55b06d/internal/ccall/common/emit.c:2668:32: warning: implicit truncation from 'int' to a one-bit wide bit-field changes value from 1 to -1 [-Wsingle-bit-bitfield-constant-conversion]



go install github.com/goccy/go-graphviz/cmd/dot@v0.1.2
# github.com/goccy/go-graphviz/internal/ccall
In file included from common.c:5:
../../../../../../../../pkg/mod/github.com/goccy/go-graphviz@v0.1.2/internal/ccall/common/emit.c:165:35: warning: implicit truncation from 'int' to a one-bit wide bit-field changes value from 1 to -1 [-Wsingle-bit-bitfield-constant-conversion]
../../../../../../../../pkg/mod/github.com/goccy/go-graphviz@v0.1.2/internal/ccall/common/emit.c:2540:24: warning: implicit truncation from 'int' to a one-bit wide bit-field changes value from 1 to -1 [-Wsingle-bit-bitfield-constant-conversion]
../../../../../../../../pkg/mod/github.com/goccy/go-graphviz@v0.1.2/internal/ccall/common/emit.c:2596:35: warning: implicit truncation from 'int' to a one-bit wide bit-field changes value from 1 to -1 [-Wsingle-bit-bitfield-constant-conversion]
../../../../../../../../pkg/mod/github.com/goccy/go-graphviz@v0.1.2/internal/ccall/common/emit.c:2602:35: warning: implicit truncation from 'int' to a one-bit wide bit-field changes value from 1 to -1 [-Wsingle-bit-bitfield-constant-conversion]
../../../../../../../../pkg/mod/github.com/goccy/go-graphviz@v0.1.2/internal/ccall/common/emit.c:2612:31: warning: implicit truncation from 'int' to a one-bit wide bit-field changes value from 1 to -1 [-Wsingle-bit-bitfield-constant-conversion]
../../../../../../../../pkg/mod/github.com/goccy/go-graphviz@v0.1.2/internal/ccall/common/emit.c:2623:31: warning: implicit truncation from 'int' to a one-bit wide bit-field changes value from 1 to -1 [-Wsingle-bit-bitfield-constant-conversion]
../../../../../../../../pkg/mod/github.com/goccy/go-graphviz@v0.1.2/internal/ccall/common/emit.c:2628:31: warning: implicit truncation from 'int' to a one-bit wide bit-field changes value from 1 to -1 [-Wsingle-bit-bitfield-constant-conversion]
../../../../../../../../pkg/mod/github.com/goccy/go-graphviz@v0.1.2/internal/ccall/common/emit.c:2641:28: warning: implicit truncation from 'int' to a one-bit wide bit-field changes value from 1 to -1 [-Wsingle-bit-bitfield-constant-conversion]
../../../../../../../../pkg/mod/github.com/goccy/go-graphviz@v0.1.2/internal/ccall/common/emit.c:2650:33: warning: implicit truncation from 'int' to a one-bit wide bit-field changes value from 1 to -1 [-Wsingle-bit-bitfield-constant-conversion]
../../../../../../../../pkg/mod/github.com/goccy/go-graphviz@v0.1.2/internal/ccall/common/emit.c:2659:32: warning: implicit truncation from 'int' to a one-bit wide bit-field changes value from 1 to -1 [-Wsingle-bit-bitfield-constant-conversion]
../../../../../../../../pkg/mod/github.com/goccy/go-graphviz@v0.1.2/internal/ccall/common/emit.c:2668:32: warning: implicit truncation from 'int' to a one-bit wide bit-field changes value from 1 to -1 [-Wsingle-bit-bitfield-constant-conversion]

@goccy goccy closed this as completed in #85 May 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants