Bug 34832 - rejects "i"(static_const_var) without -O2
Summary: rejects "i"(static_const_var) without -O2
Status: RESOLVED INVALID
Alias: None
Product: gcc
Classification: Unclassified
Component: inline-asm (show other bugs)
Version: 4.1.2
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-01-17 18:23 UTC by Stas Sergeev
Modified: 2008-01-18 22:04 UTC (History)
1 user (show)

See Also:
Host: x86_64, i386
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments
test case (84 bytes, text/plain)
2008-01-17 18:24 UTC, Stas Sergeev
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Stas Sergeev 2008-01-17 18:23:21 UTC
Hi.

Opening per suggestion in Bug 23200.

The following program:
---
int main()
{
    static const int i = 1;
    asm volatile ("" :: "i"(i));
    return i;
}
---

gives this when compiled without -O2:
---
asc1.c: In function 'main':
asc1.c:4: warning: asm operand 0 probably doesn't match constraints
asc1.c:4: error: impossible constraint in 'asm'
---

Using -O2 makes it to compile.
Comment 1 Stas Sergeev 2008-01-17 18:24:06 UTC
Created attachment 14961 [details]
test case
Comment 2 Andrew Pinski 2008-01-18 22:04:08 UTC
    static const int i = 1;

i is not a constant integal expression in C.  It is in C++.  With optimization, we "inline" the value.