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

The Archive Base Latest Questions

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

I’m using the following flags, but still I m not able to get this

  • 0

I’m using the following flags, but still I m not able to get this warning:

pointer of type void * used in arithmetic

Flags used:

-O2 -Werror -Wall -Wno-main -Wno-format-zero-length -Wpointer-arith -Wmissing-prototypes -Wstrict-prototypes -Wswitch -Wshadow -Wcast-qual -Wwrite-strings -Wno-sign-compare -Wno-pointer-sign -Wno-attributes  -fno-strict-aliasing     

-Wpointer-arith should catch this type of warning, but I’m not able to get this warning:

pointer of type void * used in arithmetic

Which specific cflag should be used to get this warning?

Edit: my mistake, it is there as part of a macro check which is not defined. 🙁 By defining that macro, I’m able to get that error.

  • 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-13T09:07:34+00:00Added an answer on May 13, 2026 at 9:07 am

    You’re right. -Wpointer-arith should give you a warning as per the documentation.

    I have just tried the following program (with intentional error):

    ~/code/samples$ cat foo.c
    #include <stdio.h>
    int main (int argc, char **argv)
    {
      void * bar;
      void * foo;
      foo = bar + 1;
      return 0;
    }
    

    I have compiled the program with just the -Wpointer-arith option, and all your options as listed above. Both attempts threw up the desired warning. I am using gcc version 4.3.4 (Debian 4.3.4-6).:

    ~/code/samples$ gcc -Wpointer-arith foo.c
    foo.c: In function ‘main’:
    foo.c:6: warning: pointer of type ‘void *’ used in arithmetic
    

    and

    ~/code/samples$ gcc -O2 -Werror -Wall -Wno-main -Wno-format-zero-length -Wpointer-arith -Wmissing-prototypes -Wstrict-prototypes -Wswitch -Wshadow -Wcast-qual -Wwrite-strings -Wno-sign-compare -Wno-pointer-sign -Wno-attributes -fno-strict-aliasing foo.c
    cc1: warnings being treated as errors
    foo.c: In function ‘main’:
    foo.c:6: error: pointer of type ‘void *’ used in arithmetic
    

    The compiler does throw up the warning if you give it the ‘right’ code. So, I would recommend you examine why it is you expect this warning. Maybe the code you’re compiling has changed?

    One possible clue I can give you: foo = bar + 1; in the code above triggers the warning. But foo = bar ++; will not (You get a different warning). So if your code uses increment (or decrement) operators on pointers, it will probably not trigger the warning.

    I know this is not a direct answer, but I hope this helps you focus your investigation.

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

Sidebar

Related Questions

No related questions found

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.