#1 nested includes with relative paths are incorrectly resolved

closed-fixed
nobody
None
5
2015-02-04
2006-11-06
No

mcpp fails to honour source file precedence if
relative paths within include files are involved.

mcpp is configured with flags --enable-replace-cpp,
system compiler is GCC (2.95 fwiw but should be
irrelevant).

Steps to reproduce:
1. copy those file below into subdir, naming them as
indicated.

--8<-- [subdir/wi.c] --
#include "subdir/wi.h"
const char *s = CERTAINLY_UNDEFINED_IN_SYSTEM_STDIO;
-->8-------------------

--8<-- [subdir/wi.h] --
#include "stdio.h"
-->8-------------------

--8<-- [subdir/stdio.h] --
#define CERTAINLY_UNDEFINED_IN_SYSTEM_STDIO "blabla";
-->8-------------------

Convenience script to generate testcase
--8<-- [gentestcase.sh] --
mkdir subdir
cat <<EOF > subdir/wi.c
#include "subdir/wi.h"
const char *s = CERTAINLY_UNDEFINED_IN_SYSTEM_STDIO;
EOF
cat <<EOF > subdir/wi.h
#include "stdio.h"
EOF
cat <<EOF > subdir/stdio.h
#define CERTAINLY_UNDEFINED_IN_SYSTEM_STDIO "blabla"
EOF
-->8-------------------

2. run mcpp -I. subdir/wi.c

Expected result (as generated by cpp):
# 1 "subdir/wi.c"
# 1 "subdir/wi.h" 1
# 1 "subdir/stdio.h" 1

# 1 "subdir/wi.h" 2

# 1 "subdir/wi.c" 2

const char *s = "blabla" ;

Actual result (as generated by mcpp):
# 1 "subdir/wi.c"
# 1 "/[...]/mcpp/src//"
# 1 "/[...]/mcpp/src/subdir/wi.h"
# 1 "/usr/include/stdio.h"
[...] ^ wrong include file picked up!
# 645 "/usr/include/stdio.h"

# 2 "/[...]/mcpp/src/subdir/wi.h"
# 2 "subdir/wi.c"
const char *s = CERTAINLY_UNDEFINED_IN_SYSTEM_STDIO;

As you can easily spot, mcpp resorts to the system
header stdio.h, which invalidates the assignment
later on.

This example is derived from a real world case,
therefore it is a real bug that needs to be tackled
for mcpp to become a worthwhile replacement for cpp.

Discussion

  • Kiyoshi Matsui

    Kiyoshi Matsui - 2006-11-07

    Logged In: YES
    user_id=1509677

    Thanks for the bug reporting!

    mcpp V.2.5 had not that bug. I introduced the bug at V.2.6.

    Please apply the next mcpp-2.6.1-patch3.diff. Or wait the
    coming release of mcpp V.2.6.2 about a week later.

     
  • Kiyoshi Matsui

    Kiyoshi Matsui - 2006-12-09
    • status: open --> closed-fixed
     

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks