[Bug c/51677] New: don't suggest giving main() __attribute__((const))

b.r.longbons at gmail dot com gcc-bugzilla@gcc.gnu.org
Sun Dec 25 15:38:00 GMT 2011


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

             Bug #: 51677
           Summary: don't suggest giving main() __attribute__((const))
    Classification: Unclassified
           Product: gcc
           Version: 4.7.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: b.r.longbons@gmail.com


With -O -Wsuggest-attribute=const, the following line will generate a warning:
int main() {}

This behavior is bad for 2 reasons:
1. Having an empty main() is quite useful for testing, as it allows linking to
succeed.
2. __attribute__((const)) is only meaningful when you can call the function.

Tested: 4.6.{0..2}, trunk r182496



More information about the Gcc-bugs mailing list