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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T17:23:05+00:00 2026-06-14T17:23:05+00:00

I maintain an open source program and one of my users reported that it

  • 0

I maintain an open source program and one of my users reported that it won’t compile under clang, which I’ve never used before. One of the errors that I’m getting is *Warning: qualifier on function type ‘junky_t’ (aka ‘void (const int &, const int &)’) has unspecified behavior.*. I’ve created a small program that demonstrates the issue:

typedef void junky_t(const int &foo,const int &bar);

class demo {
public:;
    const junky_t *junk;
};

And here’s what happens when I try to compile:

$clang -DHAVE_CONFIG_H  -g -g -O3 -Wall -MD -Wpointer-arith -Wshadow -Wwrite-strings -Wcast-align -Wredundant-decls -Wdisabled-optimization -Wfloat-equal -Wmultichar -Wmissing-noreturn -Woverloaded-virtual -Wsign-promo -funit-at-a-time -Weffc++  -D_FORTIFY_SOURCE=2  -MT demo.o -MD -MP -c -o demo.o demo.cpp

demo.cpp:5:5: warning: qualifier on function type 'junky_t' (aka 'void (const int &, const int &)') has unspecified behavior
    const junky_t *junk;
    ^~~~~~~~~~~~~
1 warning generated.

That is, class demo has a function pointer to a function that has a signature that takes a number of const references. The const in the class demo is supposed to prevent junk from being changed. However apparently it’s ambiguous because the function itself might be considered const, which it is not. I do not have a problem compiling this with gcc or llvm but it will not compile with clang on a Mac. What should I do?

  • 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-14T17:23:06+00:00Added an answer on June 14, 2026 at 5:23 pm

    This is not unspecified behavior. The warning of clang is wrong. Your code is legal c++. The Standard (C++11) states, that cv-qualifiers on top of a function type are ignored.

    Hence, it doesn’t make any sense to put a const qualifier on top of a function type. If you want your pointer to be const then write

    junky_t * const junk;

    otherwise just write

    junky_t * junk;

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

Sidebar

Related Questions

I maintain 2 identities one for open source development - which doesn't really contain
I maintain an open source program that builds with autoconf. Right now I'm having
I wrote, and maintain, an open-source tool called reposurgeon that edits version-control repository histories
I maintain GPSD, a widely-deployed open-source service daemon that monitors GPSes and other geodetic
I maintain an applet that helps users to upload photos to our service. The
I maintain an open source python project. Right now it supports python 2.4, 2.5,
need a technology (open source or build myself) usable from C# that allows me
I've recently implemented a couple of similar-sized web applications, one of which used a
The question An open source program uses CVS for version control. I would like
I'm integrating open source c program with Java program. I'd tried to use JNI

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.