composite_types is called in c-decl.c to merge function declarations, but in c-typeck.c to merge the types of two arms of a COND_EXPR. The former should result in a union of traits of the inputs, which composite_types computes, but the latter should give the intersection of traits unless the C standard says otherwise. In particular, when TREE_READONLY is set for a function type, that means that this function has no side effect, i.e. it is pure. When a cond expression yields a function type, it is pure only if both functions are pure. When a call is made through a COND_EXPR which is improperly marked as yielding a pure function pointer, and the result is ignored, the actual function call is not emitted.
Likewise, when we merge the type of a function with a noreturn attribute with the type of a function without that attribute, merging the types for a COND_EXPR should yield a function type without this attribute. -- Summary: composite_types called to do two different things Product: gcc Version: 4.2.0 Status: UNCONFIRMED Keywords: wrong-code Severity: normal Priority: P3 Component: c AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: amylaar at gcc dot gnu dot org http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28289