What does qualified/unqualified type mean?

I'm reading a book on C and it has the following text there


1
2
3
4
5
6
7
8
9
10
  The Constraints portion of Section 6.3.2.2 of the ANSI C Standard includes the phrase:
Each argument shall have a type such that its value may be assigned to an object with the unqualified
version of the type of its corresponding parameter.
This says that argument passing is supposed to behave like assignment.
Thus, a diagnostic message must be produced unless an object of type const char ** may be
assigned a value of type char **.To find out whether this assignment is legal, flip to the section
on simple assignment, Section 6.3.16.1, which includes the following constraint:
One of the following shall hold:…
• Both operands are pointers to qualified or unqualified versions of compatible types, and the
type pointed to by the left has all the qualifiers of the type pointed to by the right.


i don't understand what qualified type and unqualified type mean here. Can someone explain?
And can someone explain the gist of what's written here?
Last edited on
As it references C standard, it means cv-qualifiers. Those are type properties which restrict possible manipulation with type. More info: http://en.cppreference.com/w/cpp/language/cv
> I'm reading a book on C++ and it has the following text there
> The Constraints portion of Section 6.3.2.2 of the ANSI C Standard includes the phrase:
> Each argument shall have a type such that its value may be assigned to an object with the unqualified
> version of the type of its corresponding parameter.
> This says that argument passing is supposed to behave like assignment.


It would have been better if this C++ book had mentioned what the C++ Standard has to say about it:
When a function is called, each parameter shall be initialized with its corresponding argument


This says that argument passing is supposed to behave like assignment
C++ unequivocally says that argument passing is initialisation.

1
2
3
4
5
6
7
8
9
10
11
12
13
// references must be initialised (formal_parameter  must be initialized)
void foo( int& formal_parameter ) ; 

int main()
{
     int actual_argument = 34 ;
     foo( actual_argument ) ;  // initialise foo's formal_parameter with actual_argument

     const int const_qualified_int = 34 ;
     foo( const_qualified_int ) ; // *** error ***
     // *** can't initialize foo's formal_parameter (reference to int)
     // *** to refer to const_qualified_int 
}

http://coliru.stacked-crooked.com/a/4f8a62a40bf57fad
I'm sorry, i mistyped it's actually "Extreme C programming", the book i mean.
Even in C the semantics of passing parameters is the semantics of initialisation.

That
Each argument shall have a type such that its value may be assigned to an object with the unqualified version of the type of its corresponding parameter.

does not mean
This says that argument passing is supposed to behave like assignment.


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#include <stdio.h>

// didactic: const qualified parameter pased by value
int foo( const int arg ) 
{ 
    #ifdef TRY_ASSIGNMENT
    arg = 3 ; // *** error *** can't assign to arg 
    #endif // TRY_ASSIGNMENT
    
    return arg - 3 ; 
}

int main()
{
    puts( "this is fine" ) ;
    return foo(3) ; // fine, arg is initialised with 3 
}

http://coliru.stacked-crooked.com/a/ed2a820339bad0ee

'the type of its corresponding parameter' is const int.
'the unqualified version of the type of its corresponding parameter' is int
And we can assign 3 to an object of type int
Therefore, const int arg can be initialised with 3; ie. we can pass 3 as the argument to the function.
Last edited on
Topic archived. No new replies allowed.