[Bug 1791425] Re: Compiler error: constexpr with bitfields.

Juhani Numminen juhaninumminen0 at gmail.com
Wed Sep 26 16:17:16 UTC 2018


Reassigned to gcc-7, which is the source package of the actual compiler,
while gcc-defaults only provides metapackages.

** Package changed: gcc-defaults (Ubuntu) => gcc-7 (Ubuntu)

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

Title:
  Compiler error: constexpr with bitfields.

Status in gcc-defaults:
  Unknown
Status in gcc-7 package in Ubuntu:
  New

Bug description:
  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)

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



More information about the foundations-bugs mailing list