Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

memcpy "discards qualifiers" warning #578

Closed
AnnaKornfeldSimpson opened this issue Oct 26, 2018 · 2 comments
Closed

memcpy "discards qualifiers" warning #578

AnnaKornfeldSimpson opened this issue Oct 26, 2018 · 2 comments

Comments

@AnnaKornfeldSimpson
Copy link
Collaborator

AnnaKornfeldSimpson commented Oct 26, 2018

For the following example, the compiler gives a "discards qualifiers" warning on src:

array_ptr<const uint8_t> src = ...;
array_ptr<uint8_t> dst = ...;
memcpy<uint8_t>(dst, src, size);

The warning:

warning: passing '_Array_ptr<const uint8_t>'  to parameter of type '_Array_ptr<uint8_t>' discards
      qualifiers [-Wincompatible-pointer-types-discards-qualifiers]
        memcpy<uint8_t>(tmp, (_Array_ptr<const uint8_t>)srcData, srcDataSize);
                             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/local/lib/clang/6.0.0/include/string_checked.h:65:36: note: passing argument to parameter 'src'
      here
             const void * restrict src : itype(restrict _Array_ptr<const T>) byte_count(n),
                                   ^
1 warning generated.

Why is this warning occurring? There's definitely a const T right there in the listing of src.

Occurs on Linux, built from master this evening.

@dtarditi
Copy link
Contributor

PR #581 revamped the implementation of generic functions extensively. This issue no longer seems to appear.

@AnnaKornfeldSimpson
Copy link
Collaborator Author

I also can no longer repro this; thanks!

Machiry pushed a commit to Machiry/checkedc-clang that referenced this issue Jan 21, 2022
* The function `specialCaseVarIntros` incorrectly identified void pointers as
  vararg parameters. They were still constrained to be WILD, so it did not
  affect the solution, but it could cause the wrong reason to appear in the
  root cause analysis. 
* Change constraint generation for `void*` parameters so that they generate
  a single root cause  instead of two. This makes the root cause analysis more
  useful for programs using large amounts of void pointers.
* Also verify the number of pointers affected in the `root_cause.c` test.

Co-authored-by: Aaron Eline <aaron@correctcomputation.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants