[Bug 106] New: Should expoit warn_unused_result GCC attribute

[email protected]
Newsgroups gmane.comp.java.vm.sablevm.bugs
Message-ID <[email protected]>
http://sablevm.org/bugs/show_bug.cgi?id=106

           Summary: Should expoit warn_unused_result GCC attribute
           Product: SableVM
           Version: unspecified
          Platform: PC
               URL: http://gcc.gnu.org/onlinedocs/gcc-3.4.3/gcc/Function-
                    Attributes.html#Function-Attributes
        OS/Version: Linux
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: default
        AssignedTo: [email protected]
        ReportedBy: [email protected]
         QAContact: [email protected]


GCC offers an extension (in form of an attribute) that allows us to generate
a warning if the result returned by a function marked with this attribute is
ignored.

From:
http://gcc.gnu.org/onlinedocs/gcc-3.4.3/gcc/Function-Attributes.html#Function-Attributes

"The warn_unused_result attribute causes a warning to be emitted if a caller
of the function with this attribute does not use its return value. This is
useful for functions where not checking the result is either a security
problem or always a bug, such as realloc.

          int fn () __attribute__ ((warn_unused_result));
          int foo ()
          {
            if (fn () < 0) return -1;
            fn ();
            return 0;
          }
     
results in warning on line 5."

SableVM contains many function that return JNI_ERR in case of an error and
with this attribute we could ensure that values returned by these functions
are not ignored.



------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.
You are the QA contact for the bug, or are watching the QA contact.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.