patchgperf - Patches: patch #7383, Fix error when generated C code is...

 
 

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

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

Submitter:  Erik Johansson <erijo>
Submitted:  Fri 12 Nov 2010 10:38:03 AM UTC
   
 
Category:  None Priority:  5 - Normal
Status:  Done Privacy:  Public
Assigned to:  haible Open/Closed:  Closed

Sun 27 Nov 2016 05:29:26 PM UTC, comment #1: 

Thanks. Your patch looks good.

However, I happened to fix https://savannah.gnu.org/bugs/?37071 by reducing complexity (giving up on inlining the lookup function entirely) rather than by adding even more #ifs to this fragile area. It fixes your "How to reproduce the problem" steps.

Bruno Haible <haible>
Group administrator
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>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by haible (Posted a comment)
  • -email is unavailable- added by erijo (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

     

    Follow 4 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2016-11-27 haible StatusNone Done
        Assigned toNone haible
        Open/ClosedOpen Closed
    2010-11-12 erijo Attached File- Added Fix-error-when-generated-C-code-is-compiled-as-C.patch, #21990

    Back to the top

    Powered by Savane 3.13-f8d8.
    Corresponding source code