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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T13:10:07+00:00 2026-05-13T13:10:07+00:00

GCC treats these two function declarations as equivalent: void F(int* a) { } void

  • 0

GCC treats these two function declarations as equivalent:

void F(int* a) { }
void F(int* const a) { }

test.cpp: In function ‘void F(int*)’:

test.cpp:235: error: redefinition of ‘void F(int*)’

test.cpp:234: error: ‘void F(int*)’ previously defined here

This makes some sense because a caller will always ignore the const in this case… it only affects the usage of the parameter ‘a’ inside of the function.

What I’m wondering is where (if anywhere) the standard says that it’s specifically OK to discard qualifiers on pointers used as function arguments for the purpose of overload resolution.

(My real issue is that I’d like to figure out where GCC strips these pointless qualifiers internally, and since the C++ frontend of GCC is littered with comments referencing the standard, the relevant section of the standard might help me find the correct spot.)

  • 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-13T13:10:08+00:00Added an answer on May 13, 2026 at 1:10 pm

    Standard says in 8.3.5/3 that for the purposes of determining the function type any cv-qualifiers that directly qualify the parameter type are deleted. I.e. it literally says that a function declared as

    void foo(int *const a);
    

    has function type void (int *).

    A pedantic person might argue that this is not conclusive enough to claim that the above declaration should match the definition like this one

    void foo(int *a)
    {
    }
    

    or that it should make the code with dual declaration (as in your example) ill-formed, since neither of these concepts are described in the standard in terms of function types.

    I mean, we all know that these const were intended to be ignored for all external purposes, but so far I was unable to find the wording in the standard that would conclusively state exactly that. Maybe I missed something.

    Actually, in 13.1/3 it has a “Note” that says that function declarations with equivalent parameter declarations (as defined in 8.3.5) declare the same function. But it is just a note, it is non-normative, which suggests that somewhere in the standard there should be some normative text on the same issue.

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

Sidebar

Related Questions

GCC seem to think that I am trying to make a function call in
gcc 4.4.2 c89 I have a function that has to run (config_relays). It make
GCC gives a warning implicit declaration of function foo when you use foo() before
gcc 4.4.1 I am using the read function to read in a wave file.
GCC 4.4.1, C99 I am using size_t , and size_t is an unsigned int
I am unsure how exactly emacs lisp treats function objects, is there a hidden
On 64-bit architectures, long int , according to gcc is at least an int64_t
gcc 4.4.2 I have installed apache runtime portable. apr-1.3.9 ./configure make make test make
Code [GCC, compiled with -O2 flag] int main() { vector< vector<int> > matrixa(8); int
GCC has a very verbose format for certain template error messages: ... some_class<A,B,C> [with

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.