Forum Stats

  • 3,758,167 Users
  • 2,251,349 Discussions


warn_unused_result attribute works in C++ but not C?

nemequ Member Posts: 5

I just noticed that sunCC in 12.6 supports the warn_unused_result attribute (yay!), but not suncc. It seems like an odd restriction; is it intentional?

Quick test case:


int test_unused_result(void) {

  return 1729;


int main(int argc, char* argv[]) {

  (void) argc;

  (void) argv;


  if (test_unused_result() != 1729)

    return EXIT_FAILURE;

  return EXIT_SUCCESS;


Best Answer

  • Maxim Kartashev-Oracle
    Maxim Kartashev-Oracle Member Posts: 64
    edited Feb 26, 2018 3:49AM Accepted Answer

    Front-ends of all three Studio compilers (CC, cc and f90) are totally separate, so while some features such as pragmas, attributes, or compiler options are supported by all compilers, others are not.

    The warn_unused_result attribute was implemented in the C++ compiler a couple of years ago because there was a demand for it in a large open-source application. We can log an enhancement request to support this attribute for the C compiler in the next version.


This discussion has been closed.