llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
28.6k stars 11.82k forks source link

llvm-gcc segfaults on void (*f)(enum b); if b not declared #4638

Closed llvmbot closed 13 years ago

llvmbot commented 15 years ago
Bugzilla Link 4266
Resolution FIXED
Resolved on Dec 02, 2010 02:01
Version unspecified
OS Linux
Reporter LLVM Bugzilla Contributor
CC @efriedma-quic

Extended Description

  1. Create a file test.c with the line

    void (*f)(enum b);

  2. Run llvm-gcc -c test.c

  3. llvm-gcc crashes:


$ llvm-gcc -c test.c test.c:1: warning: 'enum b' declared inside parameter list test.c:1: warning: its scope is only this definition or declaration, which is probably not what you want test.c:1: internal compiler error: Segmentation fault Please submit a full bug report, with preprocessed source if appropriate. See <URL:http://llvm.org/bugs/> for instructions.

I have llvm and llvm-gcc svn head from today. Architecture is i386.

llvmbot commented 13 years ago

Yes, dragonegg handles this correctly.

lattner commented 13 years ago

Fixed in clang, and presumably dragonegg.

llvmbot commented 15 years ago

It's crashing at line 1247 of llvm-types.cpp, presumably because TYPE_SIZE(ArgTy) is null (forward declaration).

1242 #ifdef LLVM_TARGET_ENABLE_REGPARM 1243 // Allow the target to mark this as inreg. 1244 if (INTEGRAL_TYPE_P(ArgTy) || POINTER_TYPE_P(ArgTy) || 1245 SCALAR_FLOAT_TYPE_P(ArgTy)) 1246 LLVM_ADJUST_REGPARM_ATTRIBUTE(PAttributes, ArgTy, 1247 TREE_INT_CST_LOW(TYPE_SIZE(ArgTy)), 1248 local_regparam, local_fp_regparam); 1249 #endif // LLVM_TARGET_ENABLE_REGPARM

llvmbot commented 15 years ago

By the way, I forgot to mention that I ran into this when compiling real-world tested and working code (elinks browser). There I think the enum type was defined completely and it still crashed, but when I minimized it this is what I came up with, and adding an enum definition makes the crash go away. So I'm not entirely sure if it's this same bug or a different one, but it certainly seems sufficiently similar to suspect that they have a common cause.

efriedma-quic commented 15 years ago

See also bug 3730.