Bug 1713865

Summary: gcc 9 regression: "error: requested alignment is not an integer constant"
Product: [Fedora] Fedora Reporter: Kalev Lember <klember>
Component: gccAssignee: Jakub Jelinek <jakub>
Status: CLOSED ERRATA QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 30CC: davejohansen, dmalcolm, fweimer, jakub, jwakely, law, mpolacek, msebor, nickc
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2019-09-07 12:54:05 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 1675396    

Description Kalev Lember 2019-05-25 09:45:05 UTC
The following code compiles fine on gcc 8, but errors out on gcc 9 with "error: requested alignment is not an integer constant":

#include <algorithm>
#include <cstddef>
struct One {};
struct Two {};
static constexpr const size_t ALIGNMENT = std::max(alignof(One), alignof(Two));
struct Foo { alignas(ALIGNMENT) char value; };

This is a minimal reproducer based on mmapper FTBFS from https://bugzilla.redhat.com/show_bug.cgi?id=1675396

Comment 1 Marek Polacek 2019-05-28 14:24:57 UTC
Looks like this regressed with r261971.  I'll open an upstream PR.

Comment 2 Kalev Lember 2019-05-28 15:07:00 UTC
Great, thanks for tracking that down!

Comment 3 Marek Polacek 2019-06-03 17:51:50 UTC
Reduced test by Matthew:

constexpr unsigned long a(const unsigned long b) { return b; }
const unsigned long c = a(alignof(int));
alignas(c) char d;

Comment 4 Marek Polacek 2019-06-13 14:37:51 UTC
Fixed for GCC 9.2 and 10.  Should be in the next Fedora update.

Comment 5 Kalev Lember 2019-06-13 14:46:50 UTC
Awesome, thanks!

Comment 6 Kalev Lember 2019-09-07 12:54:05 UTC
This is now fixed in gcc 9.2.1. Thanks!