public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/48911] New: [C++0x]An error that a valid array subscript
@ 2011-05-06 5:54 sscrisk at gmail dot com
2011-05-06 9:28 ` [Bug c++/48911] [C++0x] Error for " paolo.carlini at oracle dot com
` (5 more replies)
0 siblings, 6 replies; 7+ messages in thread
From: sscrisk at gmail dot com @ 2011-05-06 5:54 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48911
Summary: [C++0x]An error that a valid array subscript
Product: gcc
Version: 4.6.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: sscrisk@gmail.com
Source:
int main()
{
{
constexpr int array[1] = {0};
constexpr int i = array[0]; // OK.
}
{
constexpr int array[1] = {};
constexpr int i = array[0]; // error: array subscript out of bound. Why?
}
}
Compile errors:
a.cpp: In function 'int main()':
a.cpp:5:17: warning: unused variable 'i' [-Wunused-variable]
a.cpp:9:28: error: array subscript out of bound
a.cpp:9:17: warning: unused variable 'i' [-Wunused-variable]
Access to array[0] is valid. But, compiler says "that's an error."
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/48911] [C++0x] Error for valid array subscript
2011-05-06 5:54 [Bug c++/48911] New: [C++0x]An error that a valid array subscript sscrisk at gmail dot com
@ 2011-05-06 9:28 ` paolo.carlini at oracle dot com
2011-05-06 11:05 ` jakub at gcc dot gnu.org
` (4 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: paolo.carlini at oracle dot com @ 2011-05-06 9:28 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48911
Paolo Carlini <paolo.carlini at oracle dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Last reconfirmed| |2011.05.06 09:27:51
CC| |jason at gcc dot gnu.org
Summary|[C++0x]An error that a |[C++0x] Error for valid
|valid array subscript |array subscript
Ever Confirmed|0 |1
--- Comment #1 from Paolo Carlini <paolo.carlini at oracle dot com> 2011-05-06 09:27:51 UTC ---
Confirmed mainline and 4_6-branch.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/48911] [C++0x] Error for valid array subscript
2011-05-06 5:54 [Bug c++/48911] New: [C++0x]An error that a valid array subscript sscrisk at gmail dot com
2011-05-06 9:28 ` [Bug c++/48911] [C++0x] Error for " paolo.carlini at oracle dot com
@ 2011-05-06 11:05 ` jakub at gcc dot gnu.org
2011-05-06 14:16 ` jason at gcc dot gnu.org
` (3 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: jakub at gcc dot gnu.org @ 2011-05-06 11:05 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48911
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |jakub at gcc dot gnu.org
--- Comment #2 from Jakub Jelinek <jakub at gcc dot gnu.org> 2011-05-06 11:00:19 UTC ---
Better testcase:
// PR c++/48911
// { dg-do compile }
// { dg-options "-std=c++0x" }
struct A
{
constexpr A () : a (6) {}
int a;
};
int
main ()
{
constexpr int a[1] = { 0 };
constexpr int i = a[0];
constexpr int b[1] = { };
constexpr int j = b[0];
constexpr char c[2] = "a";
constexpr char k = c[1];
constexpr char d[2] = "";
constexpr char l = d[1];
constexpr wchar_t e[2] = L"a";
constexpr wchar_t m = e[1];
constexpr wchar_t f[2] = L"";
constexpr wchar_t n = f[1];
constexpr A g[2] = { A () };
constexpr A o = g[0];
constexpr A p = g[1];
}
which covers also the case where ary is not CONSTRUCTOR, but STRING_CST.
I think we want to to the len check as done right now, but if index is above
len, we shouldn't error or set non-constant unconditionally, instead we should
check domain of TREE_TYPE (oldary). If it is within the range, we want to
return zero of the appropriate type for PODs, not sure what exactly for
constexpr non-PODs.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/48911] [C++0x] Error for valid array subscript
2011-05-06 5:54 [Bug c++/48911] New: [C++0x]An error that a valid array subscript sscrisk at gmail dot com
2011-05-06 9:28 ` [Bug c++/48911] [C++0x] Error for " paolo.carlini at oracle dot com
2011-05-06 11:05 ` jakub at gcc dot gnu.org
@ 2011-05-06 14:16 ` jason at gcc dot gnu.org
2011-05-06 22:00 ` jason at gcc dot gnu.org
` (2 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: jason at gcc dot gnu.org @ 2011-05-06 14:16 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48911
Jason Merrill <jason at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |ASSIGNED
AssignedTo|unassigned at gcc dot |jason at gcc dot gnu.org
|gnu.org |
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/48911] [C++0x] Error for valid array subscript
2011-05-06 5:54 [Bug c++/48911] New: [C++0x]An error that a valid array subscript sscrisk at gmail dot com
` (2 preceding siblings ...)
2011-05-06 14:16 ` jason at gcc dot gnu.org
@ 2011-05-06 22:00 ` jason at gcc dot gnu.org
2011-05-06 22:04 ` jason at gcc dot gnu.org
2011-05-06 22:07 ` jason at gcc dot gnu.org
5 siblings, 0 replies; 7+ messages in thread
From: jason at gcc dot gnu.org @ 2011-05-06 22:00 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48911
--- Comment #3 from Jason Merrill <jason at gcc dot gnu.org> 2011-05-06 21:57:45 UTC ---
Author: jason
Date: Fri May 6 21:57:41 2011
New Revision: 173510
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=173510
Log:
PR c++/48911
* semantics.c (cxx_eval_array_reference): Handle implicit
initializers.
Added:
trunk/gcc/testsuite/g++.dg/cpp0x/constexpr-missing.C
Modified:
trunk/gcc/cp/ChangeLog
trunk/gcc/cp/semantics.c
trunk/gcc/testsuite/ChangeLog
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/48911] [C++0x] Error for valid array subscript
2011-05-06 5:54 [Bug c++/48911] New: [C++0x]An error that a valid array subscript sscrisk at gmail dot com
` (3 preceding siblings ...)
2011-05-06 22:00 ` jason at gcc dot gnu.org
@ 2011-05-06 22:04 ` jason at gcc dot gnu.org
2011-05-06 22:07 ` jason at gcc dot gnu.org
5 siblings, 0 replies; 7+ messages in thread
From: jason at gcc dot gnu.org @ 2011-05-06 22:04 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48911
--- Comment #4 from Jason Merrill <jason at gcc dot gnu.org> 2011-05-06 21:58:40 UTC ---
Author: jason
Date: Fri May 6 21:58:37 2011
New Revision: 173515
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=173515
Log:
PR c++/48911
* semantics.c (cxx_eval_array_reference): Handle implicit
initializers.
Added:
branches/gcc-4_6-branch/gcc/testsuite/g++.dg/cpp0x/constexpr-missing.C
Modified:
branches/gcc-4_6-branch/gcc/cp/ChangeLog
branches/gcc-4_6-branch/gcc/cp/semantics.c
branches/gcc-4_6-branch/gcc/testsuite/ChangeLog
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/48911] [C++0x] Error for valid array subscript
2011-05-06 5:54 [Bug c++/48911] New: [C++0x]An error that a valid array subscript sscrisk at gmail dot com
` (4 preceding siblings ...)
2011-05-06 22:04 ` jason at gcc dot gnu.org
@ 2011-05-06 22:07 ` jason at gcc dot gnu.org
5 siblings, 0 replies; 7+ messages in thread
From: jason at gcc dot gnu.org @ 2011-05-06 22:07 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48911
Jason Merrill <jason at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |RESOLVED
Resolution| |FIXED
Target Milestone|--- |4.6.1
--- Comment #5 from Jason Merrill <jason at gcc dot gnu.org> 2011-05-06 22:01:27 UTC ---
Fixed for 4.6.1.
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2011-05-06 22:07 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-05-06 5:54 [Bug c++/48911] New: [C++0x]An error that a valid array subscript sscrisk at gmail dot com
2011-05-06 9:28 ` [Bug c++/48911] [C++0x] Error for " paolo.carlini at oracle dot com
2011-05-06 11:05 ` jakub at gcc dot gnu.org
2011-05-06 14:16 ` jason at gcc dot gnu.org
2011-05-06 22:00 ` jason at gcc dot gnu.org
2011-05-06 22:04 ` jason at gcc dot gnu.org
2011-05-06 22:07 ` jason at gcc dot gnu.org
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).