Public bug reported:

GCC crashes when trying to compile the following program.

$> cat prog.cpp

struct Boolean {
        bool is_true : 1;
        constexpr explicit Boolean () : is_true(true) { }
        constexpr explicit Boolean (bool init) : is_true(init) { 
                if (is_true != Boolean().is_true)
                        is_true = false;
        }
};

int main() { Boolean x(false); }


$> g++ -O2 prog.cpp 
prog.cpp: In function ‘int main()’:
prog.cpp:10:29:   in constexpr expansion of ‘x.Boolean::Boolean(0)’
prog.cpp:10:29: internal compiler error: in cxx_eval_bit_field_ref, at 
cp/constexpr.c:2570
 int main() { Boolean x(false); }
                             ^
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-7/README.Bugs> for instructions.


Note that -O2 is required for reproducing the bug (otherwise, constexpr does 
not seem to be evaluated in the compile time). The program might seem a bit 
convoluted, but this is the minimum non-working example I was able to construct 
from a real-life scenario. The problem does not occur if line 

bool is_true : 1;

is changed to

bool is_true;


-- Marcin.

ProblemType: Bug
DistroRelease: Ubuntu 18.04
Package: g++ 4:7.3.0-3ubuntu2
ProcVersionSignature: Ubuntu 4.15.0-33.36-generic 4.15.18
Uname: Linux 4.15.0-33-generic x86_64
NonfreeKernelModules: nvidia_modeset nvidia
ApportVersion: 2.20.9-0ubuntu7.2
Architecture: amd64
CurrentDesktop: GNOME
Date: Sat Sep  8 12:51:21 2018
InstallationDate: Installed on 2014-12-10 (1367 days ago)
InstallationMedia: Ubuntu 14.10 "Utopic Unicorn" - Release amd64 (20141022.1)
SourcePackage: gcc-defaults
UpgradeStatus: Upgraded to bionic on 2018-08-13 (26 days ago)

** Affects: gcc-defaults (Ubuntu)
     Importance: Undecided
         Status: New


** Tags: amd64 apport-bug bionic

-- 
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/1791425

Title:
  Compiler error: constexpr with bitfields.

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/gcc-defaults/+bug/1791425/+subscriptions

-- 
ubuntu-bugs mailing list
ubuntu-bugs@lists.ubuntu.com
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

Reply via email to