http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47917
Summary: snprintf(..., "const string") should be optimized into memcpy Product: gcc Version: 4.6.0 Status: UNCONFIRMED Keywords: missed-optimization Severity: normal Priority: P3 Component: middle-end AssignedTo: unassig...@gcc.gnu.org ReportedBy: bur...@gcc.gnu.org Jakub wrote at http://gcc.gnu.org/ml/gcc-patches/2011-02/msg01702.html > snprintf (nml_err_msg, sizeof nml_err_msg, "Internal namelist read error"); You could just use [...] memcpy (nml_err_msg, "Internal namelist read error", sizeof "Internal namelist read error"); but snprintf above ought to be optimized into that. Except that it isn't (sprintf is). So guess something that should be improved in 4.7+.