On Jan 7, 2009, at 12:44 PM, "gnu at bluedreamer dot com" <gcc-bugzi...@gcc.gnu.org > wrote:

When a pointer to type is typedef'ed to a new type gcc incorrectly warns about
const modifier if new typedef is used in function return type.

gcc info:
dluadrianc:/home/adrianc> gcc -v
Using built-in specs.
Target: i686-pc-linux-gnu
Configured with: ../gcc-4.3.1/configure --prefix=/usr --enable- languages=c,c++
--enable-shared --enable-threads=posix
Thread model: posix
gcc version 4.3.1 (GCC)

Command line:g++ -save-temps -Wall -ansi -Wextra -pedantic -Werror const.cc
Error message:
cc1plus: warnings being treated as errors
const.cc:10: error: type qualifiers ignored on function return type

Code
# 1 "const.cc"
# 1 "<built-in>"
# 1 "<command-line>"
# 1 "const.cc"
class Foo { };

const Foo *func1()
{
  return 0;
}

typedef Foo* Bar;

const Bar func2()

The const here is applying to the pointer type and not what the pointer points to so the warning is correct.


{
  return 0;
}

int main(int , char *[])
{
  func1();
  func2();

  return 0;
}


--
Summary: Incorrect warning/error when compiling with a typedef'ed
                   ptr return type
          Product: gcc
          Version: 4.3.1
           Status: UNCONFIRMED
         Severity: minor
         Priority: P3
        Component: c++
       AssignedTo: unassigned at gcc dot gnu dot org
       ReportedBy: gnu at bluedreamer dot com
GCC build triplet: i686-pc-linux-gnu
 GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu


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

Reply via email to