From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 24066 invoked by alias); 30 Apr 2009 23:45:12 -0000 Received: (qmail 23820 invoked by uid 48); 30 Apr 2009 23:44:55 -0000 Date: Thu, 30 Apr 2009 23:45:00 -0000 Subject: [Bug c/39985] New: Type qualifiers not actually ignored on function return type X-Bugzilla-Reason: CC Message-ID: Reply-To: gcc-bugzilla@gcc.gnu.org To: gcc-bugs@gcc.gnu.org From: "anders at kaseorg dot com" Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2009-04/txt/msg03115.txt.bz2 The warning printed with -Wignored-qualifiers (“warning: type qualifiers ignored on function return type”) seems to be lying. The const on a function’s return type is not actually ignored, as can be demonstrated using typeof(). I think that the warning should be right and the typeof() behavior is wrong, but I’m not actually sure. int f(void); const int g(void); /* warning: type qualifiers ignored on function return type */ typeof(f()) a; a = 5; typeof(g()) b; b = 5; /* error: assignment of read-only variable ‘b’ */ Another thing that seems similarly strange is that a statement expression can return a const type, even though it is not an lvalue: const int x = 5; typeof( ({ x; }) ) y; y = 5; /* error: assignment of read-only variable ‘y’ */ -- Summary: Type qualifiers not actually ignored on function return type Product: gcc Version: 4.4.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: anders at kaseorg dot com http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39985