1.. title:: clang-tidy - misc-misplaced-const 2 3misc-misplaced-const 4==================== 5 6This check diagnoses when a ``const`` qualifier is applied to a ``typedef``/ 7``using`` to a pointer type rather than to the pointee, because such constructs 8are often misleading to developers because the ``const`` applies to the pointer 9rather than the pointee. 10 11For instance, in the following code, the resulting type is ``int * const`` 12rather than ``const int *``: 13 14.. code-block:: c++ 15 16 typedef int *int_ptr; 17 void f(const int_ptr ptr) { 18 *ptr = 0; // potentially quite unexpectedly the int can be modified here 19 ptr = 0; // does not compile 20 } 21 22The check does not diagnose when the underlying ``typedef``/``using`` type is a 23pointer to a ``const`` type or a function pointer type. This is because the 24``const`` qualifier is less likely to be mistaken because it would be redundant 25(or disallowed) on the underlying pointee type. 26