A large project may have a configurable build to allow optional features. Fully
eliminating a feature may require #ifdef all over the place, making the code
ugly and unmaintainable. Example: you want an OS kernel to support an embedded
systems build that lacks the normal user ID handling.

If members of a struct could be marked as being useless, then the compiler's
dead code elimination could often take the place of adding #ifdef all over the
place.

Useful attributes would be something like this:

a. readas(x)   When used as an rvalue, you get x.
b. nomem(x)    Does not take up space. Address reads as x.
c. writeas(x)  When used as an lvalue, store x.
d. nowrite     Don't bother storing to this location.

(you'd never use more than one of the last three)


-- 
           Summary: dead variable attributes
           Product: gcc
           Version: 4.2.0
            Status: UNCONFIRMED
          Severity: enhancement
          Priority: P3
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: acahalan at gmail dot com


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=26371

Reply via email to