patchGNU gperf perfect hash fn generator - Patches: patch #7383, Fix error when generated C code is...

 
 

You are not allowed to post comments on this tracker with your current authentification level.

patch #7383: Fix error when generated C code is compiled as C++

Submitted by:  Erik Johansson <erijo>
Submitted on:  Fri 12 Nov 2010 10:38:03 AM UTC  
 
Category: NonePriority: 5 - Normal
Status: NonePrivacy: Public
Assigned to: NoneOpen/Closed: Open

Fri 12 Nov 2010 10:38:03 AM UTC, original submission:

If a generated hash file in C is included in a C++ file which is compiled with inlining disabled (e.g. -O0) the process will fail in the link stage due to missing symbols.

The reason for this is that the attribute _gnu_inline_ has a different meaning for C and C++. For C code it means "inline where possible and create a standalone function". For C++ code it means "inline where possible, but don't create a standalone function". If inlining is disabled the C++ compiler will not generate any code causing the build to fail in the link stage.

Fix this by not adding the attribute if the code is compiled as C++ code with inlining disabled.

This has been discussed on bug-gperf: http://lists.gnu.org/archive/html/bug-gperf/2009-09/msg00000.html

How to reproduce the problem:
1. cd test
2. make check-c
3. echo -e '#include "cinset.c"\nint main() { in_word_set("for", 3); }' > main.cpp
4a. g++ -o main main.cpp

/tmp/ccplX60t.o: In function `main':
main.cpp:(.text+0x19): undefined reference to `in_word_set(char const*, unsigned int)'
collect2: ld returned 1 exit status

4b. g++ -O1 -o main main.cpp
=> works

5. Apply patch
6. make -C ..
7. make check-c
8a. g++ -o main main.cpp
=> works
8b. g++ -O1 -o main main.cpp
=> works

Erik Johansson <erijo>

 

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by erijo (Submitted the item)
  •  

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follows 1 latest change.

    Date Changed By Updated Field Previous Value => Replaced By
    Fri 12 Nov 2010 10:38:03 AM UTCerijoAttached File-=>Added Fix-error-when-generated-C-code-is-compiled-as-C.patch, #21990

    Back to the top


    Powered by Savane 3.1-cleanup