Opened 4 years ago

Last modified 4 years ago

#203 new defect

Polymorphic Structure and Polymorphic Structure Errors — at Initial Version

Reported by: ajbeach Owned by:
Priority: major Component: cfa-cc
Version: 1.0 Keywords:
Cc:

Description

So I am pretty sure there is more than one bug here, but I'm not entirely sure where the lines are. There are a few places nothing is found, a few times extra options are found. There are times initialization style matters and there are times it doesn't.

Just because it might be a problem I made it a bit easier to pick out each one.

// Can be changed here or on the command line.
#ifndef SHOW_ERROR
#define SHOW_ERROR 0
#endif

forall(dtype A)
struct empty {
    // Nothing.
};

forall(dtype B)
struct counter {
    int count;
};

forall(dtype C)
struct wrap_e {
    empty(C) field;
};

forall(dtype D)
struct wrap_c {
    counter(D) field;
};

forall(dtype E)
struct wrap_d {
    E * field;
};

forall(otype F)
struct wrap_o {
    F field;
};

forall(dtype G)
struct base_vtable {
    base_vtable(G) const * const parent;
};

forall(dtype H)
struct child_vtable {
    base_vtable(H) const * const parent;
};

empty(int) empty_obj = {};
empty(char) empty_obj = {};
counter(int) count_obj = {5};
counter(char) count_obj = {5};

base_vtable(int) base_vtable_instance @= { 0 };
base_vtable(char) base_vtable_instance @= { 0 };

#if SHOW_ERROR == 1
// No alternatives:
wrap_e(int) error_obj = { inner_obj };

#elif SHOW_ERROR == 2
// No alternatives:
wrap_e(char) error_obj @= { inner_obj };

#elif SHOW_ERROR == 3
// 2 alternatives:
wrap_c(int) error_obj @= { count_obj };

#elif SHOW_ERROR == 4
void local(void) {
    // 2 alternatives:
    wrap_c(char) error_obj @= { inner_obj };
}

#elif SHOW_ERROR == 5
// 2 alternatives:
child_vtable(int) child_vtable_instance = {
    &base_vtable_instance
};

#elif SHOW_ERROR == 6
// 2 alternatives:
child_vtable(char) child_vtable_instance @= {
    &base_vtable_instance
};

#elif SHOW_ERROR == 7
void local(void) {
    wrap_e(int) error_obj;
    // No alternatives:
    error_obj = (empty(int)){};
}

#elif SHOW_ERROR == 8
void local(void) {
    wrap_c(int) error_obj;
    // No alternatives:
    error_obj = (counter(int)){ 5 };
}

#endif

// Related things that do not produce errors.

int some_int = -7;
char some_char = 'c';

wrap_c(int) wrap_obj = { count_obj };
wrap_d(int) wrap_obj = { &some_int };
wrap_d(char) wrap_obj @= { &some_char };
wrap_o(int) wrap_obj = { 13 };
wrap_o(char) wrap_obj @= { 'c' };

int main(void) {
    wrap_c(int) wrap_obj = { count_obj };
    wrap_d(int) wrap_obj = { &some_int };
    wrap_d(char) wrap_obj @= { &some_char };
    wrap_o(int) wrap_obj = { 13 };
    wrap_o(char) wrap_obj @= { 'c' };
    return 0;
}

Change History (0)

Note: See TracTickets for help on using tickets.