Opened 5 years ago
Closed 5 years ago
#182 closed defect (fixed)
Static Const Global variable segfault in generated code
| Reported by: | Thierry Delisle | Owned by: | |
|---|---|---|---|
| Priority: | major | Component: | cfa-cc |
| Version: | 1.0 | Keywords: | global |
| Cc: |
Description
The following code segfaults when run:
static const char foo = -1;
int main() {}
Note:
See TracTickets
for help on using tickets.
A tough experience reproducing has these lessons.
The "static" on the constant is required (regardless of gcc versions, as discussed below).
The problem seems to happen with gcc-8 and not with gcc-6.
Specifically these configurations on plg2 show the difference.
Gets the segfault:
$ make status translator --with-target-hosts=host:debug CXXFLAGS=-Og -g CXX=g++-8 CC=gcc-8 libcfa/x64-debug CXXFLAGS=-Og -g CXX=g++-8 CC=gcc-8 DRIVER_DIR=/u0/mlbrooks/cfa-prime/build-gcc8/driver/ ARCHITECTURE=x64 CONFIGURATION=debug CFA_VERSION=1:0:0Does not get the segfault:
$ make status translator --with-target-hosts=host:debug CXXFLAGS=-Og -g CXX=g++-8 libcfa/x64-debug CXXFLAGS=-Og -g CXX=g++-8 DRIVER_DIR=/u0/mlbrooks/cfa-prime/build/driver/ ARCHITECTURE=x64 CONFIGURATION=debug CFA_VERSION=1:0:0 $ gcc --version gcc (Ubuntu 6.5.0-2ubuntu1~16.04) 6.5.0 20181026 Copyright (C) 2017 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.