Bug 53594 - [C++11] Spurious -Wuninitialized warning for member with NSDMI
Summary: [C++11] Spurious -Wuninitialized warning for member with NSDMI
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.7.0
: P3 normal
Target Milestone: ---
Assignee: Jakub Jelinek
URL:
Keywords: diagnostic
: 53629 (view as bug list)
Depends on:
Blocks:
 
Reported: 2012-06-06 16:49 UTC by Jonathan Wakely
Modified: 2012-06-25 06:55 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2012-06-11 00:00:00


Attachments
gcc48-pr53594.patch (576 bytes, patch)
2012-06-11 08:57 UTC, Jakub Jelinek
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jonathan Wakely 2012-06-06 16:49:49 UTC
template<class T, int Min>
class Range
{
    const T min = Min;
};

Range<int, 0> r;
Comment 1 Jonathan Wakely 2012-06-06 16:52:00 UTC
$ g++-4.7 -std=c++11 c.cc -c  -Wuninitialized -c
c.cc: In instantiation of 'class Range<int, 0>':
c.cc:7:15:   required from here
c.cc:4:19: warning: non-static const member 'const int Range<int, 0>::min' in class without a constructor [-Wuninitialized]

The test in class.c:check_bases_and_members doesn't appear to look for NSDMIs
Comment 2 Jonathan Wakely 2012-06-06 16:56:12 UTC
Reduced:

class Range
{
    const int min = 1;
};
Comment 3 Andrew Pinski 2012-06-11 07:57:31 UTC
*** Bug 53629 has been marked as a duplicate of this bug. ***
Comment 4 Andrew Pinski 2012-06-11 07:59:02 UTC
Confirmed.
Comment 5 Jakub Jelinek 2012-06-11 08:57:57 UTC
Created attachment 27602 [details]
gcc48-pr53594.patch

Untested fix.
Comment 6 vincenzo Innocente 2012-06-11 09:28:49 UTC
the patch compiles and fixes my test case,
I've not tested any possible side effects
Comment 7 Jakub Jelinek 2012-06-25 06:48:09 UTC
Author: jakub
Date: Mon Jun 25 06:48:04 2012
New Revision: 188925

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=188925
Log:
	PR c++/53594
	* class.c (check_bases_and_members): Avoid -Wuninitialized
	diagnostics for non-static const members or references if they
	use NSDMI.

	* g++.dg/cpp0x/nsdmi7.C: New test.

Added:
    trunk/gcc/testsuite/g++.dg/cpp0x/nsdmi7.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/class.c
    trunk/gcc/testsuite/ChangeLog
Comment 8 Jakub Jelinek 2012-06-25 06:54:12 UTC
Author: jakub
Date: Mon Jun 25 06:54:08 2012
New Revision: 188926

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=188926
Log:
	PR c++/53594
	* class.c (check_bases_and_members): Avoid -Wuninitialized
	diagnostics for non-static const members or references if they
	use NSDMI.

	* g++.dg/cpp0x/nsdmi7.C: New test.

Added:
    branches/gcc-4_7-branch/gcc/testsuite/g++.dg/cpp0x/nsdmi7.C
Modified:
    branches/gcc-4_7-branch/gcc/cp/ChangeLog
    branches/gcc-4_7-branch/gcc/cp/class.c
    branches/gcc-4_7-branch/gcc/testsuite/ChangeLog
Comment 9 Jakub Jelinek 2012-06-25 06:55:09 UTC
Fixed.