[Bug c++/12247] New: type defined using two typedefs with const modifier couse problem when using pointer to function with this type parameter

sebastian_nowak at poczta dot onet dot pl gcc-bugzilla@gcc.gnu.org
Thu Sep 11 15:39:00 GMT 2003


PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=12247

           Summary: type defined using  two typedefs with const modifier
                    couse problem when using pointer to function with this
                    type parameter
           Product: gcc
           Version: 3.2.3
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: sebastian_nowak at poczta dot onet dot pl
                CC: gcc-bugs at gcc dot gnu dot org

This simple program defines const pointer to int using two typedefs. Then a 
pointer to function with one parameter of defined earlier type is defined.
The problem is: can't assign a correct value (a correct defined funcion 
pointer) to variable of that type. When i remove 'const' from function 
parameter declaration - the compilation finish ok - but that is not a solution 
becouse i need const parameter.

// the program:
typedef  int *LPINT;
typedef const LPINT LPCINT;

typedef void (*pFUN)( LPCINT t );

void fun( const int *name )
{
}

int main( void )
{
	pFUN a = 0L;
	a = &fun;
	return 1;
}

// compilator result

gcc -D _WIN32 -D NDEBUG -D _WINDOWS -D _USRDLL -c main.cpp -o .\main.o
main.cpp: In function `int main()':
main.cpp:18: invalid conversion from `void (*)(const int*)' to `void (*)(int*)'
mingw32-make: *** [.\main.o] Error 1



More information about the Gcc-bugs mailing list