Bug 43114
Summary: | initializing constants from each other | ||||||
---|---|---|---|---|---|---|---|
Product: | [Retired] Red Hat Linux | Reporter: | roystgnr | ||||
Component: | gcc | Assignee: | Jakub Jelinek <jakub> | ||||
Status: | CLOSED NOTABUG | QA Contact: | David Lawrence <dkl> | ||||
Severity: | low | Docs Contact: | |||||
Priority: | medium | ||||||
Version: | 7.1 | ||||||
Target Milestone: | --- | ||||||
Target Release: | --- | ||||||
Hardware: | All | ||||||
OS: | Linux | ||||||
URL: | http://gcc.gnu.org/ml/gcc-bugs/2000-01/msg00941.html | ||||||
Whiteboard: | |||||||
Fixed In Version: | Doc Type: | Bug Fix | |||||
Doc Text: | Story Points: | --- | |||||
Clone Of: | Environment: | ||||||
Last Closed: | 2001-05-31 22:02:44 UTC | Type: | --- | ||||
Regression: | --- | Mount Type: | --- | ||||
Documentation: | --- | CRM: | |||||
Verified Versions: | Category: | --- | |||||
oVirt Team: | --- | RHEL 7.3 requirements from Atomic Host: | |||||
Cloudforms Team: | --- | Target Upstream Version: | |||||
Embargoed: | |||||||
Attachments: |
|
Description
roystgnr
2001-05-31 22:01:12 UTC
Created attachment 20050 [details]
minimal demonstration source code
From my testing gcc-2.95.2 does not accept it either. Some legalesse: 6.6.6 An integer constant expression shall have integer type and shall only have operands that are integer constants, enumeration constants, character constants, sizeof expressions whose results are integer constants, and floating constants that are the immediate operands of casts. Cast operators in an integer constant expression shall only convert arithmetic types to integer types, except as part of an operand to the sizeof operator. 6.6.7 More latitude is permitted for constant expressions in initializers. Such a constant expression shall be, or evaluate to, one of the following: - an arithmetic constant expression, - a null pointer constant, - an address constant, or - an address constant for an object type plus or minus an integer constant expression. 6.6.10 An implementation may accept other forms of constant expressions. 6.7.8.4 All the expressions in an initializer for an object that has static storage duration shall be constant expressions or string literals. (only included the relevant paragraphs). As you can see, your program is not valid ISO C, but according to 6.6.10 gcc could decide to accept it as constant expression, but it does not have to (unlike in C++). None of egcs 1.1.x, gcc 2.95.x, gcc-2.96-RH, gcc 3.0 or gcc 3.1 accept this. |