Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 817419
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T01:59:26+00:00 2026-05-15T01:59:26+00:00

lint produces some warning like: foo.c XXX Warning 534: Ignoring return value of function

  • 0

lint produces some warning like:

foo.c XXX Warning 534: Ignoring return value of function bar()

From the lint manual

534 Ignoring return value of function

‘Symbol’ (compare with Location) A
function that returns a value is
called just for side effects as, for
example, in a statement by itself or
the left-hand side of a comma
operator. Try: (void) function(); to
call a function and ignore its return
value. See also the fvr, fvo and fdr
flags in §5.5 “Flag Options”.

I want to get this warning, if there exists any, during compilation. Is there any option in gcc/g++ to achieve this? I had turned on -Wall but that apparently did not detect this.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T01:59:27+00:00Added an answer on May 15, 2026 at 1:59 am

    Thanks to WhirlWind and paxdiablo for the answer and comment. Here is my attempt to put the pieces together into a complete (?) answer.

    -Wunused-result is the relevant gcc option. And it is turned on by default. Quoting from gcc warning options page:

    -Wno-unused-result

    Do not warn if a caller of a function marked with attribute warn_unused_result (see
    Variable Attributes) does not use its return value. The default is -Wunused-result

    So, the solution is to apply the warn_unused_result attribute on the function.

    Here is a full example. The contents of the file unused_result.c

    int foo() { return 3; }
    
    int bar() __attribute__((warn_unused_result));
    int bar() { return 5; }
    
    int main()
    {
        foo();
        bar();    /* line 9 */
        return 0;
    }
    

    and corresponding compilation result:

    $gcc unused_result.c 
    unused_result.c: In function ‘main’:
    unused_result.c:9: warning: ignoring return value of ‘bar’, declared with attribute warn_unused_result
    

    Note again that it is not necessary to have -Wunused-result since it is default. One may be tempted to explicitly mention it to communicate the intent. Though that is a noble intent, but after analyzing the situation, my choice, however, would be against that. Because, having -Wunused-result in the compile options may generate a false sense of security/satisfaction which is not true unless the all the functions in the code base are qualified with warn_unused_result.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I like to distinguish three different types of conflict from a version control system
Is there a lint-like tool for C#? I've got the compiler to flag warnings-as-errors,
Is there something like lint (syntax checker and validator) for SQL?
I'm trying to understand some boost code which is causing PC-Lint grief and uses
I have: TotalPrice = parseInt(TotalPrice*100)/100; $('input[name=EstimatedPrice]').val(TotalPrice); $('#EstimatedPriceDisplay').text(TotalPrice); and I'm getting two warnings from lint.
I have a large source repository split across multiple projects. I would like to
My essential problem is how to make arithmetic with floats on x86 behave like
I'm looking for an XSL lint tool which is actively maintained. The only one
I have code very similiar to this: LINT_rep::Iterator::difference_type LINT_rep::Iterator::operator+(const Iterator& right)const { return (this
In code: //file main.cpp LINT a = 12; LINT b = 3; a =

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.