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 7820849
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T07:27:12+00:00 2026-06-02T07:27:12+00:00

-Wcast-qual outputs this warning on stristr()’s return line. What is the problem ? warning:

  • 0

-Wcast-qual outputs this warning on stristr()’s return line. What is the problem ?

warning: cast discards qualifiers from pointer target type

char *stristr(const char *string, const char *substring)
{
size_t stringlength = strlen(string);
char *stringlowered = malloc(stringlength + 1);
strcpy(stringlowered, string);
tolower2(stringlowered); // in my source it has a different name, sorry.

char *substringlowered = malloc(strlen(substring) + 1);
strcpy(substringlowered, substring);
tolower2(substringlowered); // in my source it has a different name, sorry.

const char *returnvalue = strstr(stringlowered, substringlowered);
if(returnvalue != NULL)
{
    size_t returnvaluelength = strlen(returnvalue);
    returnvalue = string;
    returnvalue += stringlength - returnvaluelength;
}

free(stringlowered);
free(substringlowered);

return (char *)returnvalue;
}

EDIT :
In glibc 2.15’s strstr() source code:

return (char *) haystack_start; // cast to (char *) from const char *
  • 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-06-02T07:27:14+00:00Added an answer on June 2, 2026 at 7:27 am

    You have declared returnvalue as a pointer to a const char, but then you’ve cast it to a pointer to non-const char. You’ve discarded the const qualifier, so the compiler complains that you’ve discarded it!

    The solution is either to change the return type of the function, or to find a non-const char to point at. You don’t have one in your function, so you could consider changing the argument type if you really need a non-const return type.

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

Sidebar

Related Questions

I’m using the following flags, but still I m not able to get this
I've searched on Google for an answer to this but there doesn't seem to
I am trying to make the SgmlLinkExtractor to work. This is the signature: SgmlLinkExtractor(allow=(),
I'm trying to use a custom textfield background. The problem is that the text
I'm actually trying to render an encoded polyline obtained from the Google Map Directions
I'm receiving an error while trying to install a gem called typhoeus (this is
ALL HTML 5 geolocation script is not working.And this sample geolocation site http://www.browsergeolocation.com/ is
The code generating the warning, passing argument 1 of 'isHex' with different width due
Ok I have a menu system with a menu (Dynamicly Generated from a datavbase
I am installing a library, and got this error message: xxxx@ubuntu$ make (cd num;

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.