Bug 69688 - [6 Regression] -Wsign-compare causes bogus error: size of array ‘uc_code’ is not an integral constant-expression
Summary: [6 Regression] -Wsign-compare causes bogus error: size of array ‘uc_code’ is ...
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 6.0
: P1 normal
Target Milestone: 6.0
Assignee: Marek Polacek
URL:
Keywords: rejects-valid
Depends on:
Blocks:
 
Reported: 2016-02-05 11:18 UTC by Jonathan Wakely
Modified: 2016-02-08 15:41 UTC (History)
4 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2016-02-05 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jonathan Wakely 2016-02-05 11:18:05 UTC
struct ScriptObjectFixture
{
    static const int code_size;
    static const char code[];
    static wchar_t uc_code[];

    ScriptObjectFixture()
    {
        for (int i = 0; i < code_size; i++)
            uc_code[i] = 0;
    }

};

const char ScriptObjectFixture::code[] = "x";
const int ScriptObjectFixture::code_size = sizeof(ScriptObjectFixture::code) - 1;
wchar_t ScriptObjectFixture::uc_code[ScriptObjectFixture::code_size];


$ g++ w.cc -c  -Wsign-compare
w.cc:17:68: error: size of array ‘uc_code’ is not an integral constant-expression
 wchar_t ScriptObjectFixture::uc_code[ScriptObjectFixture::code_size];
                                                                    ^

Without -Wsign-compare there's no diagnostic.

Caused by r230365
Comment 1 Richard Biener 2016-02-05 11:19:02 UTC
Confirmed.
Comment 2 Marek Polacek 2016-02-05 13:38:26 UTC
Mine.
Comment 3 Marek Polacek 2016-02-08 15:41:04 UTC
Author: mpolacek
Date: Mon Feb  8 15:40:33 2016
New Revision: 233220

URL: https://gcc.gnu.org/viewcvs?rev=233220&root=gcc&view=rev
Log:
	PR c++/69688
	* constexpr.c (clear_cv_and_fold_caches): Renamed from clear_cv_cache.
	Call clear_fold_cache.
	* cp-tree.h: Adjust declaration.
	* decl.c (finish_enum_value_list): Call clear_cv_and_fold_caches
	rather than clear_cv_cache and clear_fold_cache.
	* typeck2.c (store_init_value): Call clear_cv_and_fold_caches.

	* g++.dg/init/const12.C: New test.

Added:
    trunk/gcc/testsuite/g++.dg/init/const12.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/constexpr.c
    trunk/gcc/cp/cp-tree.h
    trunk/gcc/cp/decl.c
    trunk/gcc/cp/typeck2.c
    trunk/gcc/testsuite/ChangeLog
Comment 4 Marek Polacek 2016-02-08 15:41:26 UTC
Fixed.