This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug optimization/13643] New: __builtin_constant_p() fails to notice known value of member variable
- From: "bryner at brianryner dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 11 Jan 2004 09:50:00 -0000
- Subject: [Bug optimization/13643] New: __builtin_constant_p() fails to notice known value of member variable
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
The testcase can probably demonstrate this better than I can verbalize it.
Basically, I have an object allocated on the stack that initializes a member
variable to a constant. I then call an inlined function on the object which
wants to use __builtin_constant_p() on the member variable. The constant check
evaluates to false... it seems like the compiler should have sufficient
information to determine the value of the member variable. In particular, note
that for struct B in the test case, the |if| in the inline function is optimized
away at compile time. Therefore it seems like __builtin_constant_p() should
evaluate to true in struct A.
(It should be fairly obvious what I'm trying to do here -- eliminate an
unnecessary call to delete(NULL) when mPtr is known to be null at compile time).
--
Summary: __builtin_constant_p() fails to notice known value of
member variable
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: optimization
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: bryner at brianryner dot com
CC: gcc-bugs at gcc dot gnu dot org
GCC host triplet: i686-pc-linux-gnu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13643