c++/2660: const array initializer + template = bogus pointer

egnor-gcc@ofb.net egnor-gcc@ofb.net
Thu Apr 26 18:56:00 GMT 2001


>Number:         2660
>Category:       c++
>Synopsis:       const array initializer + template = bogus pointer
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          wrong-code
>Submitter-Id:   net
>Arrival-Date:   Thu Apr 26 18:56:01 PDT 2001
>Closed-Date:
>Last-Modified:
>Originator:     egnor-gcc@ofb.net
>Release:        gcc version 2.95.3 20010101 (prerelease)
>Organization:
>Environment:
Debian GNU/Linux 2.2
>Description:
#include <algorithm>

int main() {
        const char foo[] = "ABC";
        count(foo,foo + sizeof(foo),'\0');
        return 0;
}
>How-To-Repeat:
Compile the code included in the "description".  Run it.
I get a segmentation fault, which is clearly wrong.
gdb shows that the begin pointer passed to "count" is bogus.
If you remove "const" from the array definition, it works!!
>Fix:

>Release-Note:
>Audit-Trail:
>Unformatted:



More information about the Gcc-bugs mailing list