Custom Query (146 matches)

Filters
 
Or
 
  
 
Columns

Show under each result:


Results (67 - 69 of 146)

Ticket Owner Reporter Resolution Summary
#190 mlbrooks fixed Re-throw-resume incorrectly depends on enclosing function return type
Description
#ifdef WONT_WORK
  #define RETTYPE void
#else
  #define RETTYPE int
#endif

#include <exception.hfa>

TRIVIAL_EXCEPTION( CPU_Fire );

RETTYPE foo() {

    try {
        int x = 1 + 1;
    } catchResume ( CPU_Fire * ) {
        throwResume;
    }
}

-DWONT_WORK actual: compiler error at throwResume, from gcc:

error: void value not ignored as it ought to be

-DWONT_WORK expected, no-args actual: compiler success, linker error for no main

When the error happens, running gcc on -CFA output shows the error is coming from the return ((void)0); line of this function nested in foo.

_Bool handle(struct __cfaehm_base_exception_t *__exception_inst){
    __attribute__ ((unused)) _Bool __ret_bool;
    {
        struct CPU_Fire *__anonymous_object2220;
        if ( (__anonymous_object2220=((struct CPU_Fire *)__cfa__virtual_cast(((const struct __cfa__parent_vtable *)(&_X25_CPU_Fire_vtable_instanceS15CPU_Fire_vtable_1)), ((const struct __cfa__parent_vtable **)__exception_inst)))) ) {
            return ((void)0);
            return 1;
        }
    }

    return 0;
}
#224 Michael Brooks <mlbrooks@…> mlbrooks fixed Cannot initialize static local constant
Description

Similar to #182, except here, the user's declaration is lexically scoped as local.

int main() {
    static const char bar = -1;
    printf("done\n");
}

Expected (everywhere): Compiles successfully and runs with output done

Actual (gcc8, gcc10): Compiles successfully and segfaults on startup.

Actual (gcc6): as expected

#228 Peter A. Buhr <pabuhr@…> mlbrooks fixed To define behaviour of new-delete on empty structs
Description
struct thing{};
void ?{}( thing & ) {
    printf("ctor\n");
}
void ^?{}( thing & ) {
    printf("dtor\n");
}

int main() {
    thing * one = new();
    delete(one);
}

Current: Outputs "ctor," but not "dtor."

An explanation of current behaviour:

  • program calls new with return type thing
  • new calls malloc with sizeof(thing), which is zero
  • malloc returns 0p when asked for zero bytes
  • new calls the thing constructor with argument *0p
  • new returns 0p as the requested object, which populates main variable one
  • program calls delete with argument one, which is 0p
  • delete of 0p is a no-op

We learned that sizeof( struct{} ) is 0 in C and 1 in C++. It is currently 0 in CFA.

One option discussed:

  • sizeof(struct{}) is 0
  • new always calls malloc, requesting min(1, sizeof(T)) bytes
  • new always calls constructor with a nonzero malloc result, except when malloc is unable to allocate
  • new skips the constructor call when malloc is unable to allocate
  • delete always calls free
  • delete does not call a destructor when the argument is 0p
  • delete calls a destructor when the argument is not 0p
  • all constructor and destructor calls use a non *0p argument

Another option discussed:

  • sizeof(struct{}) is 0
  • new always calls malloc, requesting exactly sizeof(T) bytes
  • new does not call a constructor when the type's size is nonzero and malloc returns 0p
  • new calls a constructor with argument *0p when the type's size is zero
  • delete always calls free
  • delete does not call a destructor when the type's size is nonzero and the argument is 0p
  • delete calls a destructor with argument 0p when the type's size is zero
  • constructor and destructor calls use a 0p argument for {}-structs
Note: See TracQuery for help on using queries.