This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug optimization/13643] New: __builtin_constant_p() fails to notice known value of member variable


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]