• python
  • javascript
  • reactjs
  • sql
  • c#
  • java
Facebook Twitter Instagram
Devs Fixed
  • python
  • javascript
  • reactjs
  • sql
  • c#
  • java
Devs Fixed
Home ยป Resolved: Casting const void* const to const char* const produces the “ignored-qualifiers” warning, why?

Resolved: Casting const void* const to const char* const produces the “ignored-qualifiers” warning, why?

0
By Isaac Tonny on 16/03/2023 Issue
Share
Facebook Twitter LinkedIn

In this post, we will see how to resolve Casting const void* const to const char* const produces the “ignored-qualifiers” warning, why?

Question:

I don’t understand why the following code gives the “type qualifiers ignored on cast result type” warning in GCC, can you please explain?
https://godbolt.org/z/n8Ws9aTcq

Best Answer:

A non-class non-array prvalue cannot be cv-qualified.
This means that your static_cast<const char* const>(a) is exactly the same as static_cast<const char*>(a), the pointer itself isn’t const-qualified. It’s simply discarded, which is what the warning is telling you about (the second const is what is being ignored)

If you have better answer, please add a comment about this, thank you!

Source: Stackoverflow.com

c++ compiler-warnings g++
Share. Facebook Twitter LinkedIn

Related Posts

Resolved: TYPO3 SQL error: Field ‘tx_imagezoom_set’ doesn’t have a default value

26/03/2023

Resolved: std::regex_replace to replace multiple combinations

26/03/2023

Resolved: How can I copy files using the ansible.builtin.copy module and avoid conflicting file names?

26/03/2023

Comments are closed.

© 2023 DEVSFIX.COM

Type above and press Enter to search. Press Esc to cancel.