Live data from Hacker News

The Following Code Causes Segfault in Clang

llvm.org

1–10 of 40 posts

Re: The Following Code Causes Segfault in Clang

#4
While we're at segfaulting compiler's, here's what I found just a few days ago:

    python -S -c 'print("void f(){} int main(){return (" + "*"*10**7 + "f)();}")' | gcc -xc -
(This is legal C -- look it up. Don't argue with me over the practical relevance of this please)

Re: The Following Code Causes Segfault in Clang

#6

Is there some legitimate reason to want to have A's destructor called twice on a single instance?

The usual reason for explicitly calling the destructor is if you then follow it up with a call to placement new to construct a new object in the same memory, but presumably that part was not relevant to the crash and so was not included in the minimal test case.

Re: The Following Code Causes Segfault in Clang

#7
post #4

While we're at segfaulting compiler's, here's what I found just a few days ago: python -S -c 'print("void f(){} int main(){return (" + "*"*10**7 + "f)();}")' | gcc -xc - (This is legal C -- look it up. Don't argue with me over the practical relevance of this please)

What were you doing that lead to you finding this?

Re: The Following Code Causes Segfault in Clang

#8
post #7
post #4

While we're at segfaulting compiler's, here's what I found just a few days ago: python -S -c 'print("void f(){} int main(){return (" + "*"*10**7 + "f)();}")' | gcc -xc - (This is legal C -- look it up. Don't argue with me over the practical relevance of this please)

What were you doing that lead to you finding this?

printing lots of stars?

Re: The Following Code Causes Segfault in Clang

#10
post #8
post #7

Earlier quoted context omitted.

What were you doing that lead to you finding this?

printing lots of stars?

The C program doesn't print stars. It appears to just call f. It just dereferences f quite a bit before eventually calling it. (He's printing stars in Python simply because it's a more concise way to represent a million stars.)
Post reply on HN