[cfe-commits] r153723 - in /cfe/trunk: lib/CodeGen/CGDecl.cpp lib/CodeGen/ItaniumCXXABI.cpp test/CodeGenCXX/static-init.cpp

Matt Beaumont-Gay matthewbg at google.com
Fri Mar 30 12:48:43 PDT 2012


#include <stdio.h>
static void test() {
  {
    const char kFoo[] = "1234";
    printf("%c\n", kFoo[0]);
  }
  {
    const char kFoo[] = "abcd";
    printf("%c\n", kFoo[0]);
  }
}

int main() {
  test();
  return 0;
}

$ ./test-old
1
a
$ ./test-new
a
a

On Fri, Mar 30, 2012 at 12:45, Chandler Carruth <chandlerc at google.com> wrote:
> FYI, I reverted this in r153768.
>
> Matt is working on a beautiful reduction of an actual miscompile this
> causes.
>
>
> On Fri, Mar 30, 2012 at 12:37 PM, Richard Smith <richard at metafoo.co.uk>
> wrote:
>>
>> On Fri, Mar 30, 2012 at 12:33 PM, Matthieu Monrocq
>> <matthieu.monrocq at gmail.com> wrote:
>>>
>>>
>>>
>>> Le 30 mars 2012 20:41, Chandler Carruth <chandlerc at google.com> a écrit :
>>>
>>>> On Fri, Mar 30, 2012 at 1:06 AM, Richard Smith <richard at metafoo.co.uk>
>>>> wrote:
>>>>>
>>>>> Repro looks like this:
>>>>>
>>>>> extern "C" {
>>>>>   void f() { static int n = 1; }
>>>>>   void g() { static long long n = 2; }
>>>>> }
>>>>>
>>>>> The root cause seems to be that we don't mangle static locals inside an
>>>>> extern "C" block. (For reference, g++ does.)
>>>>
>>>>
>>>> This is causing pretty significant regressions for us. Is a fix in the
>>>> works? If not, I'd like to revert until we get a fix in place so that we can
>>>> make forward progress, and track down other bugs currently showing up.
>>>>
>>>>
>>>
>>> It has been reported on the mainling list that:
>>>
>>> int main(int argc, char*[]) {
>>>   switch(argc) {
>>>   case 0: { const int s[] = {0}; break; }
>>>   case 1: { const int s[] = {1, 2}; break; }
>>>   }
>>>   return 0;
>>> }
>>>
>>> was now broken, could it be due to this too ?
>>
>>
>> Yes, this is the same issue. We're merging the globals which are
>> implicitly created to hold the constant values of the 's' variables.
>
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>




More information about the cfe-commits mailing list